diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2018-04-19 18:02:11 -0400 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2018-04-19 18:02:24 -0400 |
commit | daffe03308bffc43ea343a886aab33082d83bb9c (patch) | |
tree | 1ce087c70896ff8859d2659744387e4f45e8fa23 | |
parent | d26f48a57453844ad81503fe71ba24a1d2a1a1b7 (diff) | |
parent | 28ef2de2292695815eace5f2645fe4e305768403 (diff) | |
download | rails-daffe03308bffc43ea343a886aab33082d83bb9c.tar.gz rails-daffe03308bffc43ea343a886aab33082d83bb9c.tar.bz2 rails-daffe03308bffc43ea343a886aab33082d83bb9c.zip |
Merge pull request #32645 from maneframe/skip_query_cache_merge
Fix relation merging with skip_query_cache!
-rw-r--r-- | activerecord/lib/active_record/relation/query_methods.rb | 4 | ||||
-rw-r--r-- | activerecord/test/cases/relation/merging_test.rb | 4 |
2 files changed, 6 insertions, 2 deletions
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 |