This project is archived and is in readonly mode.

#5184 ✓resolved
Akira Matsuda

ActiveRecord::Relation#merge merges other table's conditions having same attribute name

Reported by Akira Matsuda | July 23rd, 2010 @ 10:53 AM | in 3.0.2

For example,

(Developer.joins(:company).where(:name => 'david') & Company.where(:name => '37signals')).to_sql

/ generates the following SQL.

SELECT "developers".* FROM "developers" INNER JOIN "companies" ON "companies"."id" = "developers"."company_id" WHERE ("companies"."name" = '37signals')

("developers"."name" = 'david') were overwritten because ActiveRecord::Relation#merge merges all Equality conditions with same attribute name.

Attached a patch to compare table_name as well when merging.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>