From fba5e00508cdb379d3952b0eddbc20beb408cbf5 Mon Sep 17 00:00:00 2001 From: "anastasia.gorokhova-alekseeva" Date: Wed, 10 Jul 2024 19:59:20 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B8=20=D1=81=D0=B1=D0=BE=D1=80?= =?UTF-8?q?=D0=B5=20=D0=BA=D0=BE=D0=BD=D1=84=D0=B8=D0=B3=D0=BE=D0=B2=20?= =?UTF-8?q?=D0=91=D0=94=20=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D1=83?= =?UTF-8?q?=D0=B5=D0=BC=20=D1=84=D0=BB=D0=B0=D0=B3=20include=5Fhidden:=20t?= =?UTF-8?q?rue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/seamless_database_pool.rb | 4 +++- spec/seamless_database_pool_spec.rb | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/seamless_database_pool.rb b/lib/seamless_database_pool.rb index 4a63509..29d011c 100644 --- a/lib/seamless_database_pool.rb +++ b/lib/seamless_database_pool.rb @@ -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 diff --git a/spec/seamless_database_pool_spec.rb b/spec/seamless_database_pool_spec.rb index 38c5ae5..d26f28a 100644 --- a/spec/seamless_database_pool_spec.rb +++ b/spec/seamless_database_pool_spec.rb @@ -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( [