From d59d1704527de226a9927b11b32e97b8832a686b Mon Sep 17 00:00:00 2001 From: Rafael dos Santos Silva Date: Mon, 4 May 2020 21:34:25 -0300 Subject: [PATCH] FIX: PostgreSQL fallback was broken due to Rails masking exception (#9633) The PR https://github.com/rails/rails/pull/36612 changes the raised exception if the error message includes the target database name. Since the error message contains the hostname, this could be triggered when the hostname contains the database name. --- .../connection_adapters/postgresql_fallback_adapter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/active_record/connection_adapters/postgresql_fallback_adapter.rb b/lib/active_record/connection_adapters/postgresql_fallback_adapter.rb index b8bfb629099..7cc4dce92bd 100644 --- a/lib/active_record/connection_adapters/postgresql_fallback_adapter.rb +++ b/lib/active_record/connection_adapters/postgresql_fallback_adapter.rb @@ -154,7 +154,7 @@ module ActiveRecord begin connection = postgresql_connection(config) fallback_handler.initialized ||= true - rescue PG::ConnectionBad => e + rescue ::ActiveRecord::NoDatabaseError, PG::ConnectionBad => e fallback_handler.master_down fallback_handler.verify_master