From 1da6a90699da61e954267048c7382cc7ad2e384d Mon Sep 17 00:00:00 2001 From: eileencodes Date: Fri, 6 Mar 2020 16:30:08 -0500 Subject: [PATCH] Remove unnecessary creation of new hash config This line was creating a new hash config, but we should always have a hash config to lookup at this point. Previously we needed this code because the pool name was merged into the hash. Now it's an accessor on the db_config, so we have no reason to create a new hash config. Also, change env_name to name since it's only an env in a single db application or an application with no arguments for establish_connection. --- .../lib/active_record/database_configurations.rb | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/activerecord/lib/active_record/database_configurations.rb b/activerecord/lib/active_record/database_configurations.rb index 77491166a1d..442e7088271 100644 --- a/activerecord/lib/active_record/database_configurations.rb +++ b/activerecord/lib/active_record/database_configurations.rb @@ -184,17 +184,13 @@ module ActiveRecord end end - def resolve_symbol_connection(env_name, pool_name) - db_config = find_db_config(env_name) - - if db_config - config = db_config.configuration_hash.dup - db_config = DatabaseConfigurations::HashConfig.new(db_config.env_name, db_config.name, config) + def resolve_symbol_connection(name, pool_name) + if db_config = find_db_config(name) db_config.owner_name = pool_name.to_s db_config else raise AdapterNotSpecified, <<~MSG - The `#{env_name}` database is not configured for the `#{default_env}` environment. + The `#{name}` database is not configured for the `#{default_env}` environment. Available databases configurations are: