aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/relation/merger.rb25
1 files changed, 12 insertions, 13 deletions
diff --git a/activerecord/lib/active_record/relation/merger.rb b/activerecord/lib/active_record/relation/merger.rb
index 936b83261e..bda7a76330 100644
--- a/activerecord/lib/active_record/relation/merger.rb
+++ b/activerecord/lib/active_record/relation/merger.rb
@@ -139,21 +139,20 @@ module ActiveRecord
if values[:where].empty? || relation.where_values.empty?
relation.where_values + values[:where]
else
- # Remove equalities from the existing relation with a LHS which is
- # present in the relation being merged in.
+ sanitized_wheres + values[:where]
+ end
+ end
- seen = Set.new
- values[:where].each { |w|
- if w.respond_to?(:operator) && w.operator == :==
- seen << w.left
- end
- }
+ # Remove equalities from the existing relation with a LHS which is
+ # present in the relation being merged in.
+ def sanitized_wheres
+ seen = Set.new
+ values[:where].each do |w|
+ seen << w.left if w.respond_to?(:operator) && w.operator == :==
+ end
- relation.where_values.reject { |w|
- w.respond_to?(:operator) &&
- w.operator == :== &&
- seen.include?(w.left)
- } + values[:where]
+ relation.where_values.reject do |w|
+ w.respond_to?(:operator) && w.operator == :== && seen.include?(w.left)
end
end
end