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

Fix test failures caused by #20884

PostgreSQL is strict about the usage of `DISTINCT` and `ORDER BY`, which
one of the tests demonstrated. The order clause is never going to be
relevant in the query we're performing, so let's just remove it
entirely.
This commit is contained in:
Sean Griffin 2015-08-01 18:15:46 -06:00
parent cc10911199
commit 722abe1722

View file

@ -12,7 +12,9 @@ module ActiveRecord
column_type = type_for_attribute(timestamp_column.to_s)
column = "#{connection.quote_table_name(collection.table_name)}.#{connection.quote_column_name(timestamp_column)}"
query = collection.select("COUNT(*) AS size", "MAX(#{column}) AS timestamp")
query = collection
.select("COUNT(*) AS size", "MAX(#{column}) AS timestamp")
.unscope(:order)
result = connection.select_one(query)
size = result["size"]