aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/calculations.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/calculations.rb b/activerecord/lib/active_record/calculations.rb
index 09c0c979e6..ef59db915a 100644
--- a/activerecord/lib/active_record/calculations.rb
+++ b/activerecord/lib/active_record/calculations.rb
@@ -235,7 +235,8 @@ module ActiveRecord
end
calculated_data.inject(ActiveSupport::OrderedHash.new) do |all, row|
- key = associated ? key_records[row[group_alias].to_i] : type_cast_calculated_value(row[group_alias], group_column)
+ key = type_cast_calculated_value(row[group_alias], group_column)
+ key = key_records[key] if associated
value = row[aggregate_alias]
all << [key, type_cast_calculated_value(value, column, operation)]
end