From 4a68792df7f2cecf9e6d9ddb18dfe761f553eb2a Mon Sep 17 00:00:00 2001 From: eileencodes Date: Thu, 12 Apr 2018 15:40:59 -0400 Subject: Fix database.yml merging Ok so apparently you can not just have a `default:` that manually is merged in with YAML but you can also have a special "shared" config that is automatically merged. Example: ``` shared: adapter: mysql2 host: <%= ENV["DB_HOST"] || "localhost" %> username: root connect_timeout: 0 pool: 100 reconnect: true development: database: development_db adapter: mysql2 ``` To fix, only create a DatabaseConfig object when an adapter, database, or URL are present. The merging behavior for `shared` doesn't work with a 3-tier config. I don't think it worked before this change either - since Rails doesn't know which point to merge it in. That's something we may have to fix with the refactoring I'm working on. --- activerecord/lib/active_record/database_configurations.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/database_configurations.rb b/activerecord/lib/active_record/database_configurations.rb index 09aef62753..ffeed45030 100644 --- a/activerecord/lib/active_record/database_configurations.rb +++ b/activerecord/lib/active_record/database_configurations.rb @@ -43,7 +43,7 @@ module ActiveRecord # Given an env, spec and config creates DatabaseConfig structs with # each attribute set. def self.walk_configs(env_name, spec_name, config) # :nodoc: - if config["database"] || config["url"] || env_name == "default" + if config["database"] || config["url"] || config["adapter"] DatabaseConfig.new(env_name, spec_name, config) else config.each_pair.map do |sub_spec_name, sub_config| -- cgit v1.2.3