From 3f4f56aed8b2e06817741b266a533228ce594c5b Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Mon, 20 May 2013 17:38:05 -0700 Subject: save the where values in variables so we don't need to look them up all the time --- activerecord/lib/active_record/relation/merger.rb | 9 +++++---- 1 file 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 -- cgit v1.2.3