aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2015-08-01 18:15:46 -0600
committerSean Griffin <sean@thoughtbot.com>2015-08-01 18:15:46 -0600
commit722abe1722a8bcf1798fc7f7f9a8cf4dcfa28e88 (patch)
tree3eb3ce47879870a50aaace06796653e00721c159 /activerecord/lib
parentcc10911199b437a2e05e326dfbaf370826ac9d05 (diff)
downloadrails-722abe1722a8bcf1798fc7f7f9a8cf4dcfa28e88.tar.gz
rails-722abe1722a8bcf1798fc7f7f9a8cf4dcfa28e88.tar.bz2
rails-722abe1722a8bcf1798fc7f7f9a8cf4dcfa28e88.zip
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.
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/collection_cache_key.rb4
1 files changed, 3 insertions, 1 deletions
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"]