diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-11-17 17:28:40 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-11-17 17:28:40 -0800 |
commit | 80d9b724c3f2f49ce99f1c41eddbebe7cf16686d (patch) | |
tree | e9f81b1fb767c5719c6aa58eef7fb9241ca2b7bb /activerecord/lib/active_record | |
parent | c6bfd6802ae4c8e179e875a707ec42bf73d13a20 (diff) | |
download | rails-80d9b724c3f2f49ce99f1c41eddbebe7cf16686d.tar.gz rails-80d9b724c3f2f49ce99f1c41eddbebe7cf16686d.tar.bz2 rails-80d9b724c3f2f49ce99f1c41eddbebe7cf16686d.zip |
group can be done by left side only
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/relation/query_methods.rb | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 07ca2e2088..9e7503a60d 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -199,15 +199,12 @@ module ActiveRecord equalities = wheres.grep(Arel::Nodes::Equality) groups = equalities.group_by do |equality| - left = equality.left - # table, column - [left.relation.name, left.name] + equality.left end groups.each do |_, eqls| - head = eqls.first - test = eqls.inject(head) do |memo, expr| - expr == head ? expr : memo.or(expr) + test = eqls.inject(eqls.shift) do |memo, expr| + memo.or(expr) end arel = arel.where(test) end |