Skip to content

Commit ce182e4

Browse files
Make db-annotator compatible with Rails 7
Rails 7 changes the signature of the execute method that this gem calls via `super`.
1 parent e2604ee commit ce182e4

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lib/active_record/connection_adapters/mysql2_annotator_adapter.rb

+11-3
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,17 @@ def annotation=(value)
4343
annotation_comment
4444
end
4545

46-
def execute(sql, name = nil)
47-
sql = annotation_comment + sql unless @annotation.nil?
48-
super
46+
if ActiveRecord::VERSION::MAJOR >= 7
47+
# see activerecord-7.0.8.7/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:202
48+
def execute(sql, name = nil, async: false)
49+
sql = annotation_comment + sql unless @annotation.nil?
50+
super
51+
end
52+
else
53+
def execute(sql, name = nil)
54+
sql = annotation_comment + sql unless @annotation.nil?
55+
super
56+
end
4957
end
5058

5159
private

0 commit comments

Comments
 (0)