Class: ActiveRecord::StructuredEventSubscriber
- Inherits:
-
ActiveSupport::StructuredEventSubscriber
- Object
- ActiveSupport::StructuredEventSubscriber
- ActiveRecord::StructuredEventSubscriber
- Defined in:
- lib/active_record/structured_event_subscriber.rb
Overview
:nodoc:
Constant Summary collapse
- IGNORE_PAYLOAD_NAMES =
["SCHEMA", "EXPLAIN"]
Instance Method Summary collapse
Instance Method Details
#sql(event) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/active_record/structured_event_subscriber.rb', line 21 def sql(event) payload = event.payload return if IGNORE_PAYLOAD_NAMES.include?(payload[:name]) binds = nil if payload[:binds]&.any? casted_params = type_casted_binds(payload[:type_casted_binds]) binds = [] payload[:binds].each_with_index do |attr, i| attribute_name = if attr.respond_to?(:name) attr.name elsif attr.respond_to?(:[]) && attr[i].respond_to?(:name) attr[i].name else nil end filtered_params = filter(attribute_name, casted_params[i]) binds << render_bind(attr, filtered_params) end end emit_debug_event("active_record.sql", async: payload[:async], name: payload[:name], sql: payload[:sql], cached: payload[:cached], lock_wait: payload[:lock_wait], binds: binds, duration_ms: event.duration.round(2), ) end |
#strict_loading_violation(event) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/active_record/structured_event_subscriber.rb', line 9 def strict_loading_violation(event) owner = event.payload[:owner] reflection = event.payload[:reflection] emit_debug_event("active_record.strict_loading_violation", owner: owner.name, class: reflection.polymorphic? ? nil : reflection.klass.name, name: reflection.name, ) end |