Browse files

save the where values in variables so we don't need to look them up all

the time
  • Loading branch information...
1 parent 658e9e0 commit 3f4f56aed8b2e06817741b266a533228ce594c5b @tenderlove tenderlove committed May 20, 2013
Showing with 5 additions and 4 deletions.
  1. +5 −4 activerecord/lib/active_record/relation/merger.rb
View
9 activerecord/lib/active_record/relation/merger.rb
@@ -132,12 +132,13 @@ def merged_binds
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

0 comments on commit 3f4f56a

Please sign in to comment.