aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorKasper Timm Hansen <kaspth@gmail.com>2016-01-24 16:24:31 +0100
committerKasper Timm Hansen <kaspth@gmail.com>2016-01-24 16:24:31 +0100
commit8c1f248c58ba65a786ae295def325c8982e7f431 (patch)
tree29552f97c28a9d0607975acab7fa56bf893302a3 /activerecord/lib
parent1969753974f3790974fc22ea0617d2e96145284d (diff)
parent66023eccb66f327d174685686f98955030d820f2 (diff)
downloadrails-8c1f248c58ba65a786ae295def325c8982e7f431.tar.gz
rails-8c1f248c58ba65a786ae295def325c8982e7f431.tar.bz2
rails-8c1f248c58ba65a786ae295def325c8982e7f431.zip
Merge pull request #23081 from prathamesh-sonpatki/fix-cache-key-for-queries-with-offset
Fix ActiveRecord::Relation#cache_key for relations with no results
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/collection_cache_key.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/collection_cache_key.rb b/activerecord/lib/active_record/collection_cache_key.rb
index b0e555038e..b20df1c232 100644
--- a/activerecord/lib/active_record/collection_cache_key.rb
+++ b/activerecord/lib/active_record/collection_cache_key.rb
@@ -19,8 +19,14 @@ module ActiveRecord
.unscope(:order)
result = connection.select_one(query)
- size = result["size"]
- timestamp = column_type.deserialize(result["timestamp"])
+ if result.blank?
+ size = 0
+ timestamp = nil
+ else
+ size = result["size"]
+ timestamp = column_type.deserialize(result["timestamp"])
+ end
+
end
if timestamp