Skip to content

Commit 7a08a86

Browse files
committed
Remove deprecated name argument from ActiveRecord::Base.remove_connection
1 parent 94d24f4 commit 7a08a86

File tree

4 files changed

+8
-25
lines changed

4 files changed

+8
-25
lines changed

activerecord/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* Remove deprecated `name` argument from `ActiveRecord::Base.remove_connection`.
2+
3+
*Rafael Mendonça França*
4+
15
* Remove deprecated support to call `alias_attribute` with non-existent attribute names.
26

37
*Rafael Mendonça França*

activerecord/lib/active_record/connection_handling.rb

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -299,16 +299,9 @@ def connected?
299299
connection_handler.connected?(connection_specification_name, role: current_role, shard: current_shard)
300300
end
301301

302-
def remove_connection(name = nil)
303-
if name
304-
ActiveRecord.deprecator.warn(<<-MSG.squish)
305-
The name argument for `#remove_connection` is deprecated without replacement
306-
and will be removed in Rails 7.2. `#remove_connection` should always be called
307-
on the connection class directly, which makes the name argument obsolete.
308-
MSG
309-
end
302+
def remove_connection
303+
name = @connection_specification_name if defined?(@connection_specification_name)
310304

311-
name ||= @connection_specification_name if defined?(@connection_specification_name)
312305
# if removing a connection that has a pool, we reset the
313306
# connection_specification_name so it will use the parent
314307
# pool.

activerecord/test/cases/connection_adapters/connection_handler_test.rb

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -293,22 +293,6 @@ def test_a_class_using_custom_pool_and_switching_back_to_primary
293293
assert_same klass2.connection, ActiveRecord::Base.connection
294294
end
295295

296-
def test_remove_connection_with_name_argument_is_deprecated
297-
klass2 = Class.new(Base) { def self.name; "klass2"; end }
298-
299-
assert_same klass2.connection, ActiveRecord::Base.connection
300-
301-
pool = klass2.establish_connection(ActiveRecord::Base.connection_pool.db_config.configuration_hash)
302-
assert_same klass2.connection, pool.connection
303-
assert_not_same klass2.connection, ActiveRecord::Base.connection
304-
305-
assert_deprecated(ActiveRecord.deprecator) do
306-
ActiveRecord::Base.remove_connection("klass2")
307-
end
308-
ensure
309-
ActiveRecord::Base.establish_connection :arunit
310-
end
311-
312296
class ApplicationRecord < ActiveRecord::Base
313297
self.abstract_class = true
314298
end

guides/source/7_2_release_notes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ Please refer to the [Changelog][active-record] for detailed changes.
109109

110110
* Remove deprecated support to call `alias_attribute` with non-existent attribute names.
111111

112+
* Remove deprecated `name` argument from `ActiveRecord::Base.remove_connection`.
113+
112114
### Deprecations
113115

114116
### Notable changes

0 commit comments

Comments
 (0)