Skip to content

Commit 160cc33

Browse files
committed
Don't attempt to clear active connections unless we'ere connected
Right now with this middleware we are likely always connected, but I'm hoping to change that soon. This is an easy change to pull out on its own.
1 parent 4565de0 commit 160cc33

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

activerecord/lib/active_record/query_cache.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def self.install_executor_hooks(executor = ActiveSupport::Executor)
4040
executor.register_hook(self)
4141

4242
executor.to_complete do
43-
unless ActiveRecord::Base.connection.transaction_open?
43+
unless ActiveRecord::Base.connected? && ActiveRecord::Base.connection.transaction_open?
4444
ActiveRecord::Base.clear_active_connections!
4545
end
4646
end

0 commit comments

Comments
 (0)