提交 74e3539c 编写于 作者: P Pratik Naik

Ignore order for simple calculations to make postgresql happy

上级 848d6cd4
......@@ -168,7 +168,8 @@ def execute_simple_calculation(operation, column_name, distinct) #:nodoc:
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册