Skip to content

Commit 7bfce52

Browse files
authored
Fix query cache filtering (#1075)
1 parent 191510a commit 7bfce52

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

test/support/core_ext/query_cache.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@ module SqlIgnoredCache
2222
# compromising cache outside tests.
2323
def cache_sql(sql, name, binds)
2424
result = super
25-
@query_cache.delete_if { |k, v| k =~ Regexp.union(IGNORED_SQL) }
25+
26+
@query_cache.delete_if do |cache_key, _v|
27+
# Query cache key generated by `sql` or `[sql, binds]`, so need to retrieve `sql` for both cases.
28+
cache_key_sql = Array(cache_key).first
29+
Regexp.union(IGNORED_SQL).match?(cache_key_sql)
30+
end
31+
2632
result
2733
end
2834
end

0 commit comments

Comments
 (0)