提交 3df5173d 编写于 作者: J James Coleman

Test that AR query cache isn't busted when types are not same object

This is fixed in 5.0 as an ancillary part of 574f2556
but here I also add a test for the condition.

I'd previously backported the fix (and added a test) in the below
commit; this brings the fix back up to master.

(cherry picked from commit fce3dbf3)
上级 ae570a2e
......@@ -212,6 +212,26 @@ def test_query_cache_doesnt_leak_cached_results_of_rolled_back_queries
end
end
def test_query_cached_even_when_types_are_reset
Task.cache do
# Warm the cache
task = Task.find(1)
Task.connection.type_map.clear
# Preload the type cache again (so we don't have those queries issued during our assertions)
Task.connection.send(:initialize_type_map, Task.connection.type_map)
# Clear places where type information is cached
Task.reset_column_information
Task.initialize_find_by_cache
assert_queries(0) do
Task.find(1)
end
end
end
private
def middleware(&app)
executor = Class.new(ActiveSupport::Executor)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册