diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-06-25 17:36:24 -0300 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-06-25 18:35:53 -0300 |
commit | f8f4ac91203506c94d547ee0ef530bd60faf97ed (patch) | |
tree | a19da39a9d3add46aad8ca3f0ff8d807d2676ad2 /activerecord/lib/active_record | |
parent | 12ac97707997f11ebda9d7527aaff14d079a2460 (diff) | |
download | rails-f8f4ac91203506c94d547ee0ef530bd60faf97ed.tar.gz rails-f8f4ac91203506c94d547ee0ef530bd60faf97ed.tar.bz2 rails-f8f4ac91203506c94d547ee0ef530bd60faf97ed.zip |
Ensure Arel columns are typecasted properly when grouping with calculation
Fix build issue with postgresql.
Conflicts:
activerecord/lib/active_record/relation/calculations.rb
activerecord/test/cases/calculations_test.rb
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/relation/calculations.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb index 42ee4961c0..802059db21 100644 --- a/activerecord/lib/active_record/relation/calculations.rb +++ b/activerecord/lib/active_record/relation/calculations.rb @@ -295,10 +295,10 @@ module ActiveRecord end ActiveSupport::OrderedHash[calculated_data.map do |row| - key = group_columns.map { |aliaz, column| + key = group_columns.map { |aliaz, column| type_cast_calculated_value(row[aliaz], column) } - key = key.first if key.size == 1 + key = key.first if key.size == 1 key = key_records[key] if associated [key, type_cast_calculated_value(row[aggregate_alias], column_for(column_name), operation)] end] @@ -325,7 +325,7 @@ module ActiveRecord end def column_for(field) - field_name = field.to_s.split('.').last + field_name = field.respond_to?(:name) ? field.name.to_s : field.to_s.split('.').last @klass.columns.detect { |c| c.name.to_s == field_name } end |