aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-05-20 17:35:17 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-05-20 17:35:17 -0700
commit658e9e0f35104c8e47f7442b2fcd9c7b1d405787 (patch)
tree961df8dea8e33afc893dda4094fb44126499bb29 /activerecord
parent3b266bcfeaa2268cabf4afa362ea0982b92e5b4c (diff)
downloadrails-658e9e0f35104c8e47f7442b2fcd9c7b1d405787.tar.gz
rails-658e9e0f35104c8e47f7442b2fcd9c7b1d405787.tar.bz2
rails-658e9e0f35104c8e47f7442b2fcd9c7b1d405787.zip
pass where values to the helper function rather than rely on internal state
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/relation/merger.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/relation/merger.rb b/activerecord/lib/active_record/relation/merger.rb
index eea43aff0e..8e2ae9a9b1 100644
--- a/activerecord/lib/active_record/relation/merger.rb
+++ b/activerecord/lib/active_record/relation/merger.rb
@@ -137,19 +137,19 @@ module ActiveRecord
if values[:where].empty? || relation.where_values.empty?
relation.where_values + values[:where]
else
- sanitized_wheres + values[:where]
+ sanitized_wheres(relation.where_values, values[:where]) + values[:where]
end
end
# Remove equalities from the existing relation with a LHS which is
# present in the relation being merged in.
- def sanitized_wheres
+ def sanitized_wheres(lhs_wheres, rhs_wheres)
seen = Set.new
- values[:where].each do |w|
+ rhs_wheres.each do |w|
seen << w.left if w.respond_to?(:operator) && w.operator == :==
end
- relation.where_values.reject do |w|
+ lhs_wheres.reject do |w|
w.respond_to?(:operator) && w.operator == :== && seen.include?(w.left)
end
end