aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2016-01-24 13:04:36 -0500
committerRafael França <rafaelmfranca@gmail.com>2016-01-24 13:04:36 -0500
commit6b89c4a24749ed972930ad1e27308bcda48c362b (patch)
tree56ad41d7bcb562ed722d1a2d0fc7d0e959d94aba /activerecord/lib
parent9e6969412bc97494298930143c7e6e6b1434827b (diff)
parent29cf0dd9f48782c94de924a11b4fd1ad7b939dc5 (diff)
downloadrails-6b89c4a24749ed972930ad1e27308bcda48c362b.tar.gz
rails-6b89c4a24749ed972930ad1e27308bcda48c362b.tar.bz2
rails-6b89c4a24749ed972930ad1e27308bcda48c362b.zip
Merge pull request #23051 from prathamesh-sonpatki/fix-collection-cache-key
Fix AR::Relation#cache_key to remove select scope added by user
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/collection_cache_key.rb1
1 files changed, 1 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/collection_cache_key.rb b/activerecord/lib/active_record/collection_cache_key.rb
index b20df1c232..5dcc98424a 100644
--- a/activerecord/lib/active_record/collection_cache_key.rb
+++ b/activerecord/lib/active_record/collection_cache_key.rb
@@ -15,6 +15,7 @@ module ActiveRecord
column = "#{connection.quote_table_name(collection.table_name)}.#{connection.quote_column_name(timestamp_column)}"
query = collection
+ .unscope(:select)
.select("COUNT(*) AS size", "MAX(#{column}) AS timestamp")
.unscope(:order)
result = connection.select_one(query)