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

Make it work with next Rails #140

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/marginalia.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.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)
alias_method :execute_and_clear_without_marginalia, :execute_and_clear
alias_method :execute_and_clear, :execute_and_clear_with_marginalia
else
Expand Down Expand Up @@ -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
Expand Down
Loading