From 2c240c036669cbf52996ba7e7856c32bc97e59a3 Mon Sep 17 00:00:00 2001 From: Jonathan Hefner Date: Sun, 19 Nov 2023 15:49:34 -0600 Subject: [PATCH] Change disjunction to conjunction in suggestion Follow-up to #50104. The error conditions are that the adapter is spelled incorrectly __or__ the necessary gem isn't in the `Gemfile`. Therefore, to fix the error, the user must ensure that the adapter is spelled correctly __and__ the gem is in the `Gemfile`. This commit also adds `require "active_support/core_ext/string/filters"`, which technically should be included for `String#squish`. --- activerecord/lib/active_record/connection_adapters.rb | 4 +++- .../test/cases/database_configurations/resolver_test.rb | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/activerecord/lib/active_record/connection_adapters.rb b/activerecord/lib/active_record/connection_adapters.rb index 1f9a143d8af..d4be1c084de 100644 --- a/activerecord/lib/active_record/connection_adapters.rb +++ b/activerecord/lib/active_record/connection_adapters.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require "active_support/core_ext/string/filters" + module ActiveRecord module ConnectionAdapters extend ActiveSupport::Autoload @@ -32,7 +34,7 @@ module ActiveRecord raise AdapterNotFound, <<~MSG.squish Database configuration specifies nonexistent '#{adapter_name}' adapter. Available adapters are: #{@adapters.keys.sort.join(", ")}. - Ensure that the adapter is spelled correctly in config/database.yml or that you've added the necessary + Ensure that the adapter is spelled correctly in config/database.yml and that you've added the necessary adapter gem to your Gemfile if it's not in the list of available adapters. MSG end diff --git a/activerecord/test/cases/database_configurations/resolver_test.rb b/activerecord/test/cases/database_configurations/resolver_test.rb index 619b694baf5..ba65b174d30 100644 --- a/activerecord/test/cases/database_configurations/resolver_test.rb +++ b/activerecord/test/cases/database_configurations/resolver_test.rb @@ -16,7 +16,7 @@ module ActiveRecord Base.connection_handler.establish_connection "ridiculous://foo?encoding=utf8" end - assert_match "Database configuration specifies nonexistent 'ridiculous' adapter. Available adapters are: abstract, fake, mysql2, postgresql, sqlite3, trilogy. Ensure that the adapter is spelled correctly in config/database.yml or that you've added the necessary adapter gem to your Gemfile if it's not in the list of available adapters.", error.message + assert_match "Database configuration specifies nonexistent 'ridiculous' adapter. Available adapters are: abstract, fake, mysql2, postgresql, sqlite3, trilogy. Ensure that the adapter is spelled correctly in config/database.yml and that you've added the necessary adapter gem to your Gemfile if it's not in the list of available adapters.", error.message end # The abstract adapter is used simply to bypass the bit of code that