diff options
-rw-r--r-- | activerecord/lib/active_record/relation/merger.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/relation/merger.rb b/activerecord/lib/active_record/relation/merger.rb index 0f54d91d86..98afeb8cc5 100644 --- a/activerecord/lib/active_record/relation/merger.rb +++ b/activerecord/lib/active_record/relation/merger.rb @@ -145,10 +145,10 @@ module ActiveRecord # Remove equalities from the existing relation with a LHS which is # present in the relation being merged in. def reject_overwrites(lhs_wheres, rhs_wheres) - seen = Set.new - rhs_wheres.each do |w| - seen << w.left if w.respond_to?(:operator) && w.operator == :== + nodes = rhs_wheres.find_all do |w| + w.respond_to?(:operator) && w.operator == :== end + seen = Set.new(nodes) { |node| node.left } lhs_wheres.reject do |w| w.respond_to?(:operator) && w.operator == :== && seen.include?(w.left) |