diff options
author | Jon Leighton <j@jonathanleighton.com> | 2010-10-31 10:04:56 +0000 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2010-10-31 10:04:56 +0000 |
commit | d010fb13ef622bdb781e3134005fc849db4c9bea (patch) | |
tree | 8ca8beb957fb51923938c4e7befa35d44e711dba /activerecord/lib/active_record/relation/spawn_methods.rb | |
parent | fc276e5635821e65c04b8961170cc6bd3c11b923 (diff) | |
parent | 3cf85fb4fcdae65a4d5a1a5c418492ea0cf9ad6d (diff) | |
download | rails-d010fb13ef622bdb781e3134005fc849db4c9bea.tar.gz rails-d010fb13ef622bdb781e3134005fc849db4c9bea.tar.bz2 rails-d010fb13ef622bdb781e3134005fc849db4c9bea.zip |
Merge branch 'master' into nested_has_many_through
Conflicts:
activerecord/lib/active_record/associations/has_many_association.rb
activerecord/lib/active_record/associations/through_association_scope.rb
Diffstat (limited to 'activerecord/lib/active_record/relation/spawn_methods.rb')
-rw-r--r-- | activerecord/lib/active_record/relation/spawn_methods.rb | 25 |
1 files changed, 14 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..a61a3bd41c 100644 --- a/activerecord/lib/active_record/relation/spawn_methods.rb +++ b/activerecord/lib/active_record/relation/spawn_methods.rb @@ -28,17 +28,20 @@ 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 = Hash.new { |h,table| h[table] = {} } + merged_wheres = merged_wheres.reverse.reject { |w| + nuke = false + if w.respond_to?(:operator) && w.operator == :== + name = w.left.name + table = w.left.relation.name + nuke = seen[table][name] + seen[table][name] = true + end + nuke + }.reverse + end merged_relation.where_values = merged_wheres |