xing/beetle

Deprecated calls to ActiveRecord::Base

Aqualon opened this issue · 3 comments

Currently using beetle with rails 7.1 gives the warning

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!`.

Deprecation note from https://github.com/rails/rails/blob/7-1-stable/activerecord/CHANGELOG.md

Deprecate delegation from Base to connection_handler.
Calling Base.clear_all_connections!, Base.clear_active_connections!, Base.clear_reloadable_connections! and Base.flush_idle_connections! is deprecated. Please call these methods on the connection handler directly. In future Rails versions, the delegation from Base to the connection_handler will be removed.

This affects those two lines

ActiveRecord::Base.clear_active_connections! if defined?(ActiveRecord)

ActiveRecord::Base.clear_all_connections! if defined?(ActiveRecord)

In rails 7.2 this breaks with

Beetle: exception 'undefined method `clear_active_connections!' for class ActiveRecord::Base' during processing of message msgid:activities_spread_activity_to_others:119cccac-2a1d-4f19-a0a8-e29674d9b7ab

According to apidock both methods are there since rails 2.2.1
https://apidock.com/rails/v7.1.3.4/ActiveRecord/ConnectionAdapters/ConnectionHandler/clear_active_connections%21
https://apidock.com/rails/v7.1.3.4/ActiveRecord/ConnectionAdapters/ConnectionHandler/clear_all_connections%21

Beetle itself doesn't require activerecord but activesupport >= 2.3.4

s.add_runtime_dependency "activesupport", ">= 2.3.4"

So probably can be replaced without having to be too concerned about someone out there who would use latest beetle but really old rails versions.

Fixed in 2dc31dd