Skip to content

Commit

Permalink
При сборе конфигов БД используем флаг include_hidden: true
Browse files Browse the repository at this point in the history
  • Loading branch information
ngoral committed Jul 10, 2024
1 parent 4917889 commit fba5e00
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/seamless_database_pool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ def adapter_class_for(name)
# Pull out the master configuration for compatibility with such things as the Rails' rake db:*
# tasks which only support known adapters.
def master_database_configuration(database_configs)
database_configs = database_configs.configs_for.map do |conf|
# will only work for rails 6.1 and higher as for the time of writing 6.1 is the "youngest" supported
configs_attributes = Rails.version.split('.').first.to_i < 7 ? { include_replicas: true } : { include_hidden: true }
database_configs = database_configs.configs_for(**configs_attributes).map do |conf|
next conf unless conf.adapter == 'seamless_database_pool'

new_conf = conf.configuration_hash.symbolize_keys
Expand Down
2 changes: 1 addition & 1 deletion spec/seamless_database_pool_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@

it 'should pull out the master configurations for compatibility with rake db:* tasks' do
expect(master_database_configuration).to be_a(ActiveRecord::DatabaseConfigurations)
expect(master_database_configuration.configurations.size).to eq(4) # except replica
expect(master_database_configuration.configurations.size).to eq(5)

expect(master_database_configuration.configs_for(env_name: 'development').map(&:configuration_hash)).to eq(
[
Expand Down

0 comments on commit fba5e00

Please sign in to comment.