aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation/merger.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-05-20 17:38:05 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-05-20 17:38:05 -0700
commit3f4f56aed8b2e06817741b266a533228ce594c5b (patch)
treeb7261bf803d0189b7982af76d84f3c3c0e3c42ab /activerecord/lib/active_record/relation/merger.rb
parent658e9e0f35104c8e47f7442b2fcd9c7b1d405787 (diff)
downloadrails-3f4f56aed8b2e06817741b266a533228ce594c5b.tar.gz
rails-3f4f56aed8b2e06817741b266a533228ce594c5b.tar.bz2
rails-3f4f56aed8b2e06817741b266a533228ce594c5b.zip
save the where values in variables so we don't need to look them up all
the time
Diffstat (limited to 'activerecord/lib/active_record/relation/merger.rb')
-rw-r--r--activerecord/lib/active_record/relation/merger.rb9
1 files changed, 5 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/relation/merger.rb b/activerecord/lib/active_record/relation/merger.rb
index 8e2ae9a9b1..f689682cfa 100644
--- a/activerecord/lib/active_record/relation/merger.rb
+++ b/activerecord/lib/active_record/relation/merger.rb
@@ -132,12 +132,13 @@ module ActiveRecord
end
def merged_wheres
- values[:where] ||= []
+ rhs_wheres = values[:where] || []
+ lhs_wheres = relation.where_values
- if values[:where].empty? || relation.where_values.empty?
- relation.where_values + values[:where]
+ if rhs_wheres.empty? || lhs_wheres.empty?
+ lhs_wheres + rhs_wheres
else
- sanitized_wheres(relation.where_values, values[:where]) + values[:where]
+ sanitized_wheres(lhs_wheres, rhs_wheres) + rhs_wheres
end
end