aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-10-30 12:28:49 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-10-30 12:28:49 -0700
commit7d5762d2c2147f8240614997682e5e535a3e4f33 (patch)
tree5a8b67c7e32a6189a2763d68e082a7cde94e365f /activerecord
parent2b48e476540c946579007188e59fd393bdf7a163 (diff)
downloadrails-7d5762d2c2147f8240614997682e5e535a3e4f33.tar.gz
rails-7d5762d2c2147f8240614997682e5e535a3e4f33.tar.bz2
rails-7d5762d2c2147f8240614997682e5e535a3e4f33.zip
no need to merge where values if no new where values have been added
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/relation/spawn_methods.rb24
1 files changed, 13 insertions, 11 deletions
diff --git a/activerecord/lib/active_record/relation/spawn_methods.rb b/activerecord/lib/active_record/relation/spawn_methods.rb
index 648a02f1cc..d761bd3ea6 100644
--- a/activerecord/lib/active_record/relation/spawn_methods.rb
+++ b/activerecord/lib/active_record/relation/spawn_methods.rb
@@ -28,17 +28,19 @@ module ActiveRecord
merged_wheres = @where_values + r.where_values
- # Remove duplicates, last one wins.
- seen = {}
- merged_wheres = merged_wheres.reverse.reject { |w|
- nuke = false
- if w.respond_to?(:operator) && w.operator == :==
- name = w.left.name
- nuke = seen[name]
- seen[name] = true
- end
- nuke
- }.reverse
+ unless @where_values.empty?
+ # Remove duplicates, last one wins.
+ seen = {}
+ merged_wheres = merged_wheres.reverse.reject { |w|
+ nuke = false
+ if w.respond_to?(:operator) && w.operator == :==
+ name = w.left.name
+ nuke = seen[name]
+ seen[name] = true
+ end
+ nuke
+ }.reverse
+ end
merged_relation.where_values = merged_wheres