diff options
Diffstat (limited to 'activerecord/lib/active_record/relation/calculations.rb')
-rw-r--r-- | activerecord/lib/active_record/relation/calculations.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb index dddd1f46a1..d4765a6782 100644 --- a/activerecord/lib/active_record/relation/calculations.rb +++ b/activerecord/lib/active_record/relation/calculations.rb @@ -181,8 +181,11 @@ module ActiveRecord column_name = "#{connection.quote_table_name(table_name)}.#{connection.quote_column_name(column_name)}" end + result = klass.connection.exec_query(select(column_name).to_sql) + last_column = result.columns.last + klass.connection.select_all(select(column_name).arel).map! do |attributes| - klass.type_cast_attribute(attributes.keys.first, klass.initialize_attributes(attributes)) + klass.type_cast_attribute(last_column, klass.initialize_attributes(attributes)) end end |