Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: v3.2.1
Fetching contributors…

Cannot retrieve contributors at this time

22 lines (18 sloc) 0.699 kb
require 'active_support/notifications'
module ActiveRecord
class ExplainSubscriber # :nodoc:
def call(*args)
if queries = Thread.current[:available_queries_for_explain]
payload = args.last
queries << payload.values_at(:sql, :binds) unless ignore_payload?(payload)
end
end
# SCHEMA queries cannot be EXPLAINed, also we do not want to run EXPLAIN on
# our own EXPLAINs now matter how loopingly beautiful that would be.
IGNORED_PAYLOADS = %w(SCHEMA EXPLAIN)
def ignore_payload?(payload)
payload[:exception] || IGNORED_PAYLOADS.include?(payload[:name])
end
ActiveSupport::Notifications.subscribe("sql.active_record", new)
end
end
Jump to Line
Something went wrong with that request. Please try again.