From 722abe1722a8bcf1798fc7f7f9a8cf4dcfa28e88 Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Sat, 1 Aug 2015 18:15:46 -0600 Subject: 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. --- activerecord/lib/active_record/collection_cache_key.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/collection_cache_key.rb b/activerecord/lib/active_record/collection_cache_key.rb index 72b50c1d28..3c4ca3d116 100644 --- a/activerecord/lib/active_record/collection_cache_key.rb +++ b/activerecord/lib/active_record/collection_cache_key.rb @@ -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"] -- cgit v1.2.3