diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2010-01-20 02:17:35 +0530 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2010-01-20 02:17:49 +0530 |
commit | 74e3539cda914bf3cb380e8486d316c275a5f0cf (patch) | |
tree | b6923ef0cfeaee16816d69c1beaad88f15c06477 /activerecord | |
parent | 848d6cd46b93ef9b1e755449a1de7cee56e7e115 (diff) | |
download | rails-74e3539cda914bf3cb380e8486d316c275a5f0cf.tar.gz rails-74e3539cda914bf3cb380e8486d316c275a5f0cf.tar.bz2 rails-74e3539cda914bf3cb380e8486d316c275a5f0cf.zip |
Ignore order for simple calculations to make postgresql happy
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/relation/calculations.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb index 5645e7f031..e77424a64b 100644 --- a/activerecord/lib/active_record/relation/calculations.rb +++ b/activerecord/lib/active_record/relation/calculations.rb @@ -168,7 +168,8 @@ module ActiveRecord Arel::SqlLiteral.new(column_name == :all ? "*" : column_name.to_s) end - relation = select(operation == 'count' ? column.count(distinct) : column.send(operation)) + # Postgresql doesn't like ORDER BY when there are no GROUP BY + relation = except(:order).select(operation == 'count' ? column.count(distinct) : column.send(operation)) type_cast_calculated_value(@klass.connection.select_value(relation.to_sql), column_for(column_name), operation) end |