Remove more unneeded methods that should be configs

This commit is contained in:
Rafael Mendonça França 2021-08-17 22:35:22 +00:00
parent 8d6073da7d
commit 6d983e86da
No known key found for this signature in database
GPG Key ID: FC23B6D0F1EEE948
5 changed files with 12 additions and 46 deletions

View File

@ -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)

View File

@ -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}="

View File

@ -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!

View File

@ -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|

View File

@ -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: