Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ActiveRecord::ConnectionAdapters::ConnectionPool#lease_connection with Rails 7.2 #573

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion lib/identity_cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def should_use_cache? # :nodoc:
# When there are no open transactions, `current_transaction` returns a
# special `NullTransaction` object that is unjoinable, meaning we will
# use the cache.
pool.connection.current_transaction.joinable?
connection_for(pool).current_transaction.joinable?
end
end

Expand Down Expand Up @@ -257,6 +257,16 @@ def fetch_in_batches(keys, &block)
result.merge!(cache.fetch_multi(*slice, &block))
end
end

if ActiveRecord.gem_version >= Gem::Version.new("7.2.0.beta1")
def connection_for(pool)
pool.lease_connection
end
else
def connection_for(pool)
pool.connection
end
end
end
end

Expand Down
Loading