diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-12-28 19:11:02 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-12-28 19:11:02 -0800 |
commit | 54a65183e706d324fd220b5ff46c9a8dc27bfe89 (patch) | |
tree | 514b17a7849175876314b06763785875aea0df92 /activerecord/lib/active_record/relation | |
parent | ac6594921f4d8532b41a956e90ca56aa05f941be (diff) | |
download | rails-54a65183e706d324fd220b5ff46c9a8dc27bfe89.tar.gz rails-54a65183e706d324fd220b5ff46c9a8dc27bfe89.tar.bz2 rails-54a65183e706d324fd220b5ff46c9a8dc27bfe89.zip |
fix PG typecasting errors
Diffstat (limited to 'activerecord/lib/active_record/relation')
-rw-r--r-- | activerecord/lib/active_record/relation/calculations.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb index ccc14dddeb..e27c64e3c9 100644 --- a/activerecord/lib/active_record/relation/calculations.rb +++ b/activerecord/lib/active_record/relation/calculations.rb @@ -241,13 +241,16 @@ module ActiveRecord select_value = operation_over_aggregate_column(column, operation, distinct) + column_name = select_value.alias relation.select_values = [select_value] query_builder = relation.arel end - result = @klass.connection.select_value(query_builder, nil, relation.bind_values) - type_cast_calculated_value(result, column_for(column_name), operation) + result = @klass.connection.select_all(query_builder, nil, relation.bind_values) + row = result.first + value = row && row.values.first + type_cast_calculated_value(value, result.column_types[column_name], operation) end def execute_grouped_calculation(operation, column_name, distinct) #:nodoc: |