mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
7315c91d45
Calling `#remove_connection` on the handler is deprecated in favor of `#remove_connection_pool`. This change was made to support changing the return value from a hash to a `DatabaseConfig` object. `#remove_connection` will be removed in 6.2. NOTE: `#remove_connection` on `ActiveRecord::Base` will also now return a `DatabaseConfig` object. We didn't use a deprecation here since it's not documented that this method used to return a `Hash`. Co-authored-by: John Crepezzi <john.crepezzi@gmail.com>
16 lines
487 B
Ruby
16 lines
487 B
Ruby
# frozen_string_literal: true
|
|
|
|
module ConnectionHelper
|
|
def run_without_connection
|
|
original_connection = ActiveRecord::Base.remove_connection
|
|
yield original_connection.configuration_hash
|
|
ensure
|
|
ActiveRecord::Base.establish_connection(original_connection)
|
|
end
|
|
|
|
# Used to drop all cache query plans in tests.
|
|
def reset_connection
|
|
original_connection = ActiveRecord::Base.remove_connection
|
|
ActiveRecord::Base.establish_connection(original_connection)
|
|
end
|
|
end
|