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.
This commit is contained in:
eileencodes 2018-04-12 15:40:59 -04:00
parent 23d4091a1f
commit 4a68792df7
1 changed files with 1 additions and 1 deletions

View File

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