Skip to content

Commit

Permalink
Merge pull request #41147 from OuYangJinTing/fix_query_cache_is_dirty…
Browse files Browse the repository at this point in the history
…_after_perform_created

Fix ActiveRecord::ConnectionAdapters::QueryCache#dirties_query_cache
  • Loading branch information
kamipo committed Feb 1, 2021
1 parent 9f39d00 commit ffff703
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module ConnectionAdapters # :nodoc:
module QueryCache
class << self
def included(base) #:nodoc:
dirties_query_cache base, :insert, :update, :delete, :truncate, :truncate_tables,
dirties_query_cache base, :create, :insert, :update, :delete, :truncate, :truncate_tables,
:rollback_to_savepoint, :rollback_db_transaction, :exec_insert_all

base.set_callback :checkout, :after, :configure_query_cache!
Expand Down
13 changes: 13 additions & 0 deletions activerecord/test/cases/adapter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,19 @@ def setup
end
end

def test_create_with_query_cache
@connection.enable_query_cache!

count = Post.count

@connection.create("INSERT INTO posts(title, body) VALUES ('', '')")

assert_equal count + 1, Post.count
ensure
reset_fixtures("posts")
@connection.disable_query_cache!
end

def test_truncate
assert_operator Post.count, :>, 0

Expand Down

0 comments on commit ffff703

Please sign in to comment.