diff options
author | James Williams <jamesw@instructure.com> | 2018-04-19 09:27:31 -0600 |
---|---|---|
committer | James Williams <jamesw@instructure.com> | 2018-04-19 09:42:55 -0600 |
commit | 28ef2de2292695815eace5f2645fe4e305768403 (patch) | |
tree | 1c966731dfe0a5480907e49702dfb495ffa7db2a /activerecord | |
parent | 92bb3f6aaaa80fa7add94debbda6373a15f55b64 (diff) | |
download | rails-28ef2de2292695815eace5f2645fe4e305768403.tar.gz rails-28ef2de2292695815eace5f2645fe4e305768403.tar.bz2 rails-28ef2de2292695815eace5f2645fe4e305768403.zip |
Fix relation merging with skip_query_cache!
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/CHANGELOG.md | 6 | ||||
-rw-r--r-- | activerecord/lib/active_record/relation/query_methods.rb | 4 | ||||
-rw-r--r-- | activerecord/test/cases/relation/merging_test.rb | 4 |
3 files changed, 11 insertions, 3 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index d8bf7df63b..47c2a4e990 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,4 +1,8 @@ -* Add `ActiveRecord::Base.base_class?` predicate. +* Fix relation merging with skip_query_cache! + + *James Williams* + +* Add `ActiveRecord::Base.base_class?` predicate. *Bogdan Gusiev* diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 4e60863e52..a180b0f0d3 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -894,8 +894,8 @@ module ActiveRecord self end - def skip_query_cache! # :nodoc: - self.skip_query_cache_value = true + def skip_query_cache!(value = true) # :nodoc: + self.skip_query_cache_value = value self end diff --git a/activerecord/test/cases/relation/merging_test.rb b/activerecord/test/cases/relation/merging_test.rb index 074ce9454f..f53ef1fe35 100644 --- a/activerecord/test/cases/relation/merging_test.rb +++ b/activerecord/test/cases/relation/merging_test.rb @@ -78,6 +78,10 @@ class RelationMergingTest < ActiveRecord::TestCase assert_equal 1, comments.count end + def test_relation_merging_with_skip_query_cache + assert_equal Post.all.merge(Post.all.skip_query_cache!).skip_query_cache_value, true + end + def test_relation_merging_with_association assert_queries(2) do # one for loading post, and another one merged query post = Post.where(body: "Such a lovely day").first |