This project is archived and is in readonly mode.

#5234 ✓resolved
Akira Matsuda

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

Reported by Akira Matsuda | July 28th, 2010 @ 09:41 PM | in 3.0.2

When a relation being merged with another relation based on other model, its scope_for_create are wrongly overwritten.

For example, a Pirate's name are overwritten by his Ship's name in the following code.

> (Pirate.where(:name => 'Monkey D. Luffy').joins(:ship) & Ship.where(:name => 'Going Merry')).scope_for_create
 #=> {:name=>"Going Merry"}

Attached a patch for fixing this.
This patch depends on another patch for #5184 , so please apply both two patches, or the tests won't pass.

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>