diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-11-14 17:08:53 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-11-15 13:42:50 -0800 |
commit | d5a8bdb2e21bc9b22241b9e2b604e88b76398339 (patch) | |
tree | 21079aac6c5685c5bb37bcd966a85590ffb3ef03 /activerecord/lib/active_record | |
parent | ef8b845de7e06077131297a398cb7f4e81d6bb08 (diff) | |
download | rails-d5a8bdb2e21bc9b22241b9e2b604e88b76398339.tar.gz rails-d5a8bdb2e21bc9b22241b9e2b604e88b76398339.tar.bz2 rails-d5a8bdb2e21bc9b22241b9e2b604e88b76398339.zip |
create fewer relation objects
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/relation/calculations.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb index df27318678..e801cc4e65 100644 --- a/activerecord/lib/active_record/relation/calculations.rb +++ b/activerecord/lib/active_record/relation/calculations.rb @@ -273,7 +273,9 @@ module ActiveRecord group_fields = group_attrs end - group_aliases = group_fields.map { |field| column_alias_for(field) } + group_aliases = group_fields.map { |field| + column_alias_for(field) + } group_columns = group_aliases.zip(group_fields).map { |aliaz,field| [aliaz, column_for(field)] } @@ -283,7 +285,7 @@ module ActiveRecord if operation == 'count' && column_name == :all aggregate_alias = 'count_all' else - aggregate_alias = column_alias_for(operation, column_name) + aggregate_alias = column_alias_for([operation, column_name].join(' ')) end select_values = [ @@ -302,7 +304,8 @@ module ActiveRecord end } - relation = except(:group).group(group) + relation = except(:group) + relation.group_values = group relation.select_values = select_values calculated_data = @klass.connection.select_all(relation, nil, bind_values) |