diff --git a/actionpack/lib/action_controller/railtie.rb b/actionpack/lib/action_controller/railtie.rb index e902cbc1de..3e90064355 100644 --- a/actionpack/lib/action_controller/railtie.rb +++ b/actionpack/lib/action_controller/railtie.rb @@ -52,6 +52,9 @@ module ActionController options.asset_host ||= app.config.asset_host options.relative_url_root ||= app.config.relative_url_root + # Configs used in other initializers + options = options.except(:log_query_tags_around_actions) + ActiveSupport.on_load(:action_controller) do include app.routes.mounted_helpers extend ::AbstractController::Railties::RoutesHelpers.with(app.routes) diff --git a/activejob/lib/active_job/railtie.rb b/activejob/lib/active_job/railtie.rb index 91ffc32e07..8e3907f151 100644 --- a/activejob/lib/active_job/railtie.rb +++ b/activejob/lib/active_job/railtie.rb @@ -25,6 +25,9 @@ module ActiveJob options = app.config.active_job options.queue_adapter ||= :async + # Configs used in other initializers + options = options.except(:log_query_tags_around_perform) + ActiveSupport.on_load(:active_job) do options.each do |k, v| k = "#{k}=" diff --git a/activerecord/lib/active_record.rb b/activerecord/lib/active_record.rb index e89636aca8..9f2ecb8a65 100644 --- a/activerecord/lib/active_record.rb +++ b/activerecord/lib/active_record.rb @@ -323,51 +323,6 @@ module ActiveRecord singleton_class.attr_accessor :verify_foreign_keys_for_fixtures self.verify_foreign_keys_for_fixtures = false - ## - # :singleton-method: - # Specify whether or not to enable adapter-level query comments. - # To enable: - # - # config.active_record.query_log_tags_enabled = true - # - # When included in +ActionController::Base+ or +ActionController::API, controller context is automatically - # updated via an +around_action+ filter. This behaviour can be disabled as follows: - # - # config.action_controller.log_query_tags_around_actions = false - # - # This behaviour can be disabled for Active Job in a similar way: - # - # config.active_job.log_query_tags_around_perform = false - singleton_class.attr_accessor :query_log_tags_enabled - self.query_log_tags_enabled = false - - ## - # :singleton-method: - # An +Array+ specifying the key/value tags to be inserted in an SQL comment. Defaults to `[ :application ]`, a - # predefined tag returning the application name. - # - # Custom values can be passed in as a +Hash+: - # - # config.active_record.query_log_tags = [ :application, { custom: 'value' } ] - # - # See +ActiveRecord::QueryLogs+ for more details - # on predefined tags and defining new tag content. - singleton_class.attr_accessor :query_log_tags - self.query_log_tags = [ :application ] - - ## - # :singleton-method: - # Specify whether or not to enable caching of query log tags. - # For applications that have a large number of queries, caching query log tags can - # provide a performance benefit when the context does not change during the lifetime - # of the request or job execution. - # - # To enable: - # - # config.active_record.cache_query_log_tags = true - singleton_class.attr_accessor :cache_query_log_tags - self.cache_query_log_tags = false - def self.eager_load! super ActiveRecord::Locking.eager_load! diff --git a/activerecord/lib/active_record/railtie.rb b/activerecord/lib/active_record/railtie.rb index 498ae46f1f..b2d207af07 100644 --- a/activerecord/lib/active_record/railtie.rb +++ b/activerecord/lib/active_record/railtie.rb @@ -32,6 +32,9 @@ module ActiveRecord config.active_record.maintain_test_schema = true config.active_record.has_many_inversing = false config.active_record.sqlite3_production_warning = true + config.active_record.query_log_tags_enabled = false + config.active_record.query_log_tags = [ :application ] + config.active_record.cache_query_log_tags = false config.active_record.queues = ActiveSupport::InheritableOptions.new @@ -210,7 +213,7 @@ To keep using the current cache store, you can turn off cache versioning entirel end initializer "active_record.set_configs" do |app| - configs = app.config.active_record + configs = app.config.active_record.except(:query_log_tags_enabled, :query_log_tags, :cache_query_log_tags) config.after_initialize do configs.each do |k, v| diff --git a/guides/source/configuring.md b/guides/source/configuring.md index e18bc71713..f1aef2c178 100644 --- a/guides/source/configuring.md +++ b/guides/source/configuring.md @@ -517,6 +517,8 @@ in controllers and views. This defaults to `false`. Defaults to `[ :application ]`, a predefined tag returning the application name. * `config.active_record.cache_query_log_tags` specifies whether or not to enable caching of query log tags. + For applications that have a large number of queries, caching query log tags can provide a performance benefit when + the context does not change during the lifetime of the request or job execution. Defaults to `false`. The MySQL adapter adds one additional configuration option: