1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Ignore order for simple calculations to make postgresql happy

This commit is contained in:
Pratik Naik 2010-01-20 02:17:35 +05:30
parent 848d6cd46b
commit 74e3539cda

View file

@ -168,7 +168,8 @@ module ActiveRecord
Arel::SqlLiteral.new(column_name == :all ? "*" : column_name.to_s) Arel::SqlLiteral.new(column_name == :all ? "*" : column_name.to_s)
end 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) type_cast_calculated_value(@klass.connection.select_value(relation.to_sql), column_for(column_name), operation)
end end