aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authoreileencodes <eileencodes@gmail.com>2018-04-12 15:40:59 -0400
committereileencodes <eileencodes@gmail.com>2018-04-12 16:40:35 -0400
commit4a68792df7f2cecf9e6d9ddb18dfe761f553eb2a (patch)
treef201ab33b9c1e4918a60f89e3b1c9940c0b6938e /activerecord/lib
parent23d4091a1f9ef4693050823264fc1b6d345f1b7a (diff)
downloadrails-4a68792df7f2cecf9e6d9ddb18dfe761f553eb2a.tar.gz
rails-4a68792df7f2cecf9e6d9ddb18dfe761f553eb2a.tar.bz2
rails-4a68792df7f2cecf9e6d9ddb18dfe761f553eb2a.zip
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.
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/database_configurations.rb2
1 files changed, 1 insertions, 1 deletions
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|