diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-10-30 13:25:49 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-10-30 13:25:49 -0700 |
commit | 296467fcc40bb3c6a4f42dedc267eb4f313843a9 (patch) | |
tree | d4f76606772fe52acbae25a56d3ece6126300691 /activerecord/lib/active_record/relation | |
parent | cbca12f9086826dd7243c7c847deea89bbe026b1 (diff) | |
download | rails-296467fcc40bb3c6a4f42dedc267eb4f313843a9.tar.gz rails-296467fcc40bb3c6a4f42dedc267eb4f313843a9.tar.bz2 rails-296467fcc40bb3c6a4f42dedc267eb4f313843a9.zip |
only returning where values for the corresponding relation, also filtering where value hash based on table name [#5234 state:resolved] [#5184 state:resolved]
Diffstat (limited to 'activerecord/lib/active_record/relation')
-rw-r--r-- | activerecord/lib/active_record/relation/spawn_methods.rb | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/relation/spawn_methods.rb b/activerecord/lib/active_record/relation/spawn_methods.rb index d761bd3ea6..a61a3bd41c 100644 --- a/activerecord/lib/active_record/relation/spawn_methods.rb +++ b/activerecord/lib/active_record/relation/spawn_methods.rb @@ -30,13 +30,14 @@ module ActiveRecord unless @where_values.empty? # Remove duplicates, last one wins. - seen = {} + 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 - nuke = seen[name] - seen[name] = true + name = w.left.name + table = w.left.relation.name + nuke = seen[table][name] + seen[table][name] = true end nuke }.reverse |