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

Address deprecation of ActiveRecord::Base.connection in Rails 7.2 #102

Conversation

joshuay03
Copy link
Contributor

@joshuay03 joshuay03 commented Apr 5, 2024

Context: rails/rails#51349

Ensures that applications using config.active_record.permanent_connection_checkout = :disallowed are supported from Rails 7.2 onwards. This was what this PR started as, but this would require a significant API change looking at how the #start and #clean APIs are used.

Addresses the deprecation of ActiveRecord::Base.connection in favour of ActiveRecord::Base.lease_connection as of Rails 7.2.

There's one more usage of .connection but that seems to be getting removed in #101.

@joshuay03 joshuay03 mentioned this pull request Apr 5, 2024
@joshuay03 joshuay03 changed the title Support disallowing permanent connection checkouts Support disallowing permanent connection checkouts with Rails 7.2 Apr 5, 2024
@joshuay03 joshuay03 force-pushed the support-disallowing-permanent-connection-checkouts branch from 6b4ffc3 to 1be54f9 Compare April 5, 2024 10:33
@ghiculescu
Copy link
Contributor

I think this usage also needs to be updated:

@connection ||= ConnectionWrapper.new(connection_class.connection)

Otherwise you get a "Called deprecated ActiveRecord::Base.connection method." deprecation warning.

@joshuay03 joshuay03 force-pushed the support-disallowing-permanent-connection-checkouts branch 2 times, most recently from bd4c01f to 393c01a Compare June 4, 2024 03:23
@joshuay03 joshuay03 changed the title Support disallowing permanent connection checkouts with Rails 7.2 Address deprecation of ActiveRecord::Base.connection in Rails 7.2 Jun 4, 2024
@joshuay03 joshuay03 force-pushed the support-disallowing-permanent-connection-checkouts branch from 393c01a to 77f66d1 Compare June 4, 2024 03:34
@joshuay03
Copy link
Contributor Author

@ghiculescu Addressed 👍🏽

Copy link
Member

@etagwerker etagwerker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joshuay03 @ghiculescu Looks good, thank you!

@etagwerker etagwerker merged commit 79b0876 into DatabaseCleaner:main Jun 5, 2024
14 of 24 checks passed
@joshuay03 joshuay03 deleted the support-disallowing-permanent-connection-checkouts branch June 5, 2024 23:35
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.

None yet

3 participants