active_record-sql_analyzer icon indicating copy to clipboard operation
active_record-sql_analyzer copied to clipboard

Support activerecord 6, activerecord 7, and Ruby 3

Open natetarrh opened this issue 1 year ago • 1 comments

Starting with activerecord 6, transaction materialization is deferred until query execution, so reorder our execute monkeypatch to run the query and then log it.

Starting with activerecord 7, the "real work" method is now named raw_execute, so patch that one when that version is detected instead.

Starting with Ruby 3, kwargs need explicit delegation.

Tested on every combination of Ruby (2.7.8p225, 3.0.6p216, 3.1.4p223, 3.2.2) and activerecord (5.2.8.1, 6.0.6.1, 7.1.3). activerecord 5.2.8.1 does not support Ruby 3.

natetarrh avatar Feb 13 '24 01:02 natetarrh

If this PR is needed only for web's upgrade to Ruby 3, then I'm pretty confident that we don't actually need to do this work.

All the usages of ActiveRecord::SqlAnalyzer inweb can be safely removed. The tables + data that is currently being analyzed has actually moved to RosterRails.

See the following roster-rails PR for details: https://github.com/squareup/roster-rails/pull/105/files#r683646030

awernick avatar Feb 13 '24 07:02 awernick