Skip to content

Fix Rails 7.2 deprecation warning for ActiveRecord::Base.connection - #251

Open
benaitcheson wants to merge 1 commit into
collectiveidea:masterfrom
benaitcheson:fix-connection-deprecation-warning
Open

Fix Rails 7.2 deprecation warning for ActiveRecord::Base.connection#251
benaitcheson wants to merge 1 commit into
collectiveidea:masterfrom
benaitcheson:fix-connection-deprecation-warning

Conversation

@benaitcheson

Copy link
Copy Markdown

Rails 7.2 soft-deprecated ActiveRecord::Base.connection in favour of lease_connection (rails/rails#51230). The bare connection calls in the reservation code paths trigger this warning on every job reservation:

DEPRECATION WARNING: Called deprecated `ActiveRecord::Base.connection` method.

Either use `with_connection` or `lease_connection`.

This adds a reservation_connection helper that uses lease_connection where available and falls back to connection on older Rails versions, keeping compatibility with the full supported ActiveRecord range. Same approach as #218 and #226 for earlier deprecations.

lease_connection returns the same leased-per-thread connection that connection did, so behaviour is unchanged.

@benaitcheson

Copy link
Copy Markdown
Author

@danielmorrison / @albus522 if you have a moment, could I please get a review on this one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant