mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix database configuration when adding another config level
This is kind of hard to explain but if you have a database config with another level like this: ``` development: primary: database: "my db" variables: statement_timeout: 1000 ``` the database configurations code would chooke on the `variables` level because it didn't know what to do with it. We'd see the following error: ``` lib/active_record/database_configurations.rb:72:in `block in find_db_config': undefined method `env_name' for [nil]:Array (NoMethodError) ``` The problem here is that Rails does correctly identify this as not a real configuration but returns `[nil]` along with the others. We need to make sure to flatten the array and remove all the `nil`'s before returning the `configurations` objects. Fixes #35646
This commit is contained in:
parent
98d0f93506
commit
8f3066fccc
2 changed files with 3 additions and 1 deletions
|
@ -106,7 +106,7 @@ module ActiveRecord
|
||||||
|
|
||||||
build_db_config = configs.each_pair.flat_map do |env_name, config|
|
build_db_config = configs.each_pair.flat_map do |env_name, config|
|
||||||
walk_configs(env_name.to_s, "primary", config)
|
walk_configs(env_name.to_s, "primary", config)
|
||||||
end.compact
|
end.flatten.compact
|
||||||
|
|
||||||
if url = ENV["DATABASE_URL"]
|
if url = ENV["DATABASE_URL"]
|
||||||
build_url_config(url, build_db_config)
|
build_url_config(url, build_db_config)
|
||||||
|
|
|
@ -123,6 +123,8 @@ module TestHelpers
|
||||||
adapter: sqlite3
|
adapter: sqlite3
|
||||||
pool: 5
|
pool: 5
|
||||||
timeout: 5000
|
timeout: 5000
|
||||||
|
variables:
|
||||||
|
statement_timeout: 1000
|
||||||
development:
|
development:
|
||||||
primary:
|
primary:
|
||||||
<<: *default
|
<<: *default
|
||||||
|
|
Loading…
Reference in a new issue