From 6b2b2eabf337c8cd481b5dbf33cc1ffa61a6d32a Mon Sep 17 00:00:00 2001 From: Alex Ghiculescu Date: Mon, 5 Aug 2024 12:06:59 +1000 Subject: [PATCH 1/2] Make it work with next Rails Fix https://github.com/basecamp/marginalia/issues/139 --- lib/marginalia.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/marginalia.rb b/lib/marginalia.rb index 205c45f..267f489 100644 --- a/lib/marginalia.rb +++ b/lib/marginalia.rb @@ -13,7 +13,10 @@ def self.included(instrumented_class) alias_method :execute, :execute_with_marginalia end - if instrumented_class.private_method_defined?(:execute_and_clear) + if instrumented_class.method_defined?(:internal_execute) + alias_method :internal_execute_without_marginalia, :internal_execute + alias_method :internal_execute, :internal_execute_with_marginalia + elsif instrumented_class.private_method_defined?(:execute_and_clear) alias_method :execute_and_clear_without_marginalia, :execute_and_clear alias_method :execute_and_clear, :execute_and_clear_with_marginalia else @@ -67,6 +70,10 @@ def annotate_sql(sql) sql end + def internal_execute_with_marginalia(sql, *args, **options) + internal_execute_without_marginalia(annotate_sql(sql), *args, **options) + end + def execute_with_marginalia(sql, *args) execute_without_marginalia(annotate_sql(sql), *args) end From 8363d73b40ef9e2ef56ba454e7d25dc0ff879e11 Mon Sep 17 00:00:00 2001 From: Alex Ghiculescu Date: Mon, 5 Aug 2024 12:12:31 +1000 Subject: [PATCH 2/2] Update marginalia.rb --- lib/marginalia.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/marginalia.rb b/lib/marginalia.rb index 267f489..49374af 100644 --- a/lib/marginalia.rb +++ b/lib/marginalia.rb @@ -13,7 +13,7 @@ def self.included(instrumented_class) alias_method :execute, :execute_with_marginalia end - if instrumented_class.method_defined?(:internal_execute) + if instrumented_class.private_method_defined?(:internal_execute) alias_method :internal_execute_without_marginalia, :internal_execute alias_method :internal_execute, :internal_execute_with_marginalia elsif instrumented_class.private_method_defined?(:execute_and_clear)