File tree Expand file tree Collapse file tree 5 files changed +13
-11
lines changed
actionpack/lib/action_controller Expand file tree Collapse file tree 5 files changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -123,7 +123,7 @@ class Railtie < Rails::Railtie # :nodoc:
123
123
app . config . active_record . query_log_tags |= [ :action ]
124
124
125
125
ActiveSupport . on_load ( :active_record ) do
126
- ActiveRecord ::QueryLogs . taggings . merge! (
126
+ ActiveRecord ::QueryLogs . taggings = ActiveRecord :: QueryLogs . taggings . merge (
127
127
controller : -> ( context ) { context [ :controller ] &.controller_name } ,
128
128
action : -> ( context ) { context [ :controller ] &.action_name } ,
129
129
namespaced_controller : -> ( context ) {
Original file line number Diff line number Diff line change @@ -93,7 +93,9 @@ class Railtie < Rails::Railtie # :nodoc:
93
93
app . config . active_record . query_log_tags |= [ :job ]
94
94
95
95
ActiveSupport . on_load ( :active_record ) do
96
- ActiveRecord ::QueryLogs . taggings [ :job ] = -> ( context ) { context [ :job ] . class . name if context [ :job ] }
96
+ ActiveRecord ::QueryLogs . taggings = ActiveRecord ::QueryLogs . taggings . merge (
97
+ job : -> ( context ) { context [ :job ] . class . name if context [ :job ] }
98
+ )
97
99
end
98
100
end
99
101
end
Original file line number Diff line number Diff line change @@ -102,8 +102,8 @@ def call(_context)
102
102
end
103
103
end
104
104
105
- @taggings = { }
106
- @tags = [ :application ]
105
+ @taggings = { } . freeze
106
+ @tags = [ :application ] . freeze
107
107
@prepend_comment = false
108
108
@cache_query_log_tags = false
109
109
@tags_formatter = false
@@ -115,17 +115,16 @@ class << self
115
115
attr_accessor :prepend_comment , :cache_query_log_tags # :nodoc:
116
116
117
117
def taggings = ( taggings ) # :nodoc:
118
- @taggings = taggings
118
+ @taggings = taggings . freeze
119
119
@handlers = rebuild_handlers
120
120
end
121
121
122
122
def tags = ( tags ) # :nodoc:
123
- @tags = tags
123
+ @tags = tags . freeze
124
124
@handlers = rebuild_handlers
125
125
end
126
126
127
127
def tags_formatter = ( format ) # :nodoc:
128
- @tags_formatter = format
129
128
@formatter = case format
130
129
when :legacy
131
130
LegacyFormatter
@@ -134,6 +133,7 @@ def tags_formatter=(format) # :nodoc:
134
133
else
135
134
raise ArgumentError , "Formatter is unsupported: #{ format } "
136
135
end
136
+ @tags_formatter = format
137
137
end
138
138
139
139
def call ( sql , connection ) # :nodoc:
Original file line number Diff line number Diff line change @@ -385,7 +385,7 @@ class Railtie < Rails::Railtie # :nodoc:
385
385
config . after_initialize do
386
386
if app . config . active_record . query_log_tags_enabled
387
387
ActiveRecord . query_transformers << ActiveRecord ::QueryLogs
388
- ActiveRecord ::QueryLogs . taggings . merge! (
388
+ ActiveRecord ::QueryLogs . taggings = ActiveRecord :: QueryLogs . taggings . merge (
389
389
application : Rails . application . class . name . split ( "::" ) . first ,
390
390
pid : -> { Process . pid . to_s } ,
391
391
socket : -> ( context ) { context [ :connection ] . pool . db_config . socket } ,
Original file line number Diff line number Diff line change @@ -20,8 +20,8 @@ def setup
20
20
ActiveRecord ::QueryLogs . prepend_comment = false
21
21
ActiveRecord ::QueryLogs . cache_query_log_tags = false
22
22
ActiveRecord ::QueryLogs . cached_comment = nil
23
- ActiveRecord ::QueryLogs . taggings [ :application ] = -> {
24
- "active_record"
23
+ ActiveRecord ::QueryLogs . taggings = {
24
+ application : -> { "active_record" }
25
25
}
26
26
end
27
27
@@ -185,7 +185,7 @@ def test_empty_comments_are_not_added
185
185
186
186
def test_sql_commenter_format
187
187
ActiveRecord ::QueryLogs . tags_formatter = :sqlcommenter
188
- ActiveRecord ::QueryLogs . tags = [ :application , { } ]
188
+ ActiveRecord ::QueryLogs . tags = [ :application ]
189
189
190
190
assert_queries_match ( %r{/\* application='active_record'\* /} ) do
191
191
Dashboard . first
You can’t perform that action at this time.
0 commit comments