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

Fix deprecation warning seen with ActiveRecord v 7.1 #128

Conversation

bunnymatic
Copy link

problem

With ActiveRecord v7, this gem is still working but it reports a deprecation warning.

This is from a Sinatra app with sinatra-activerecord version 2.0.2.

web    | DEPRECATION WARNING: Calling `ActiveRecord::Base.clear_active_connections! is deprecated. Please call the method directly on the connection handler; for example: `ActiveRecord::Base.connection_handler.clear_active_connections!`. (called from load at /Users/jon/.rbenv/versions/2.7.6/bin/rackup:23)

solution

This PR condititionally calls clear_active_connections! off the connection_handler for ActiveSupport versions of 7 or greater and retains the old behavior for older versions.

tests

The test suite here still passes, and I pulled this gem into my app and watched the deprecation message go away.

problem
---------

With ActiveRecord v7, this gem is still working but it reports a
deprecation warning.

This is from a Sinatra app with `sinatra-activerecord` version 2.0.2.

```
web    | DEPRECATION WARNING: Calling `ActiveRecord::Base.clear_active_connections! is deprecated. Please call the method directly on the connection handler; for example: `ActiveRecord::Base.connection_handler.clear_active_connections!`. (called from load at /Users/jon/.rbenv/versions/2.7.6/bin/rackup:23)
```

solution
---------

This PR condititionally calls `clear_active_connections!` off the
`connection_handler` for ActiveSupport versions of 7 or greater and
retains the old behavior for older versions.

tests
-----

The test suite here still passes, and I pulled this gem into my app and
watched the deprecation message go away.
@cupnoodle
Copy link
Member

Thanks a lot for the PR! 🙏 LGTM, I will merge and deploy this if the CI passes

@cupnoodle
Copy link
Member

@bunnymatic I have created another PR (#129 ) following the code changes here, and manually set environment to "development" in the rake_spec.rb file , I have merged it and released it as v2.0.27 .

Thanks for contributing!

@cupnoodle cupnoodle closed this Oct 23, 2023
@bunnymatic
Copy link
Author

perfecto. thanks.

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

2 participants