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:
parent
848d6cd46b
commit
74e3539cda
1 changed files with 2 additions and 1 deletions
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue