Skip to content

Commit 5952493

Browse files
committed
Remove deprecacated support to resolve connection using "primary" as connection specification name
1 parent e3b9779 commit 5952493

File tree

4 files changed

+7
-26
lines changed

4 files changed

+7
-26
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 deprecacated support to resolve connection using `"primary"` as connection specification name.
2+
3+
*Rafael Mendonça França*
4+
15
* Remove deprecation warning when using `:interval` column is used in PostgreSQL database.
26

37
Now, interval columns will return `ActiveSupport::Duration` objects instead of strings.

activerecord/lib/active_record/connection_adapters/abstract/connection_handler.rb

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -250,19 +250,8 @@ def retrieve_connection_pool(owner, role: ActiveRecord::Base.current_role, shard
250250
attr_reader :owner_to_pool_manager
251251

252252
# Returns the pool manager for an owner.
253-
#
254-
# Using `"primary"` to look up the pool manager for `ActiveRecord::Base` is
255-
# deprecated in favor of looking it up by `"ActiveRecord::Base"`.
256-
#
257-
# During the deprecation period, if `"primary"` is passed, the pool manager
258-
# for `ActiveRecord::Base` will still be returned.
259253
def get_pool_manager(owner)
260-
return owner_to_pool_manager[owner] if owner_to_pool_manager.key?(owner)
261-
262-
if owner == "primary"
263-
ActiveSupport::Deprecation.warn("Using `\"primary\"` as a `connection_specification_name` is deprecated and will be removed in Rails 7.0.0. Please use `ActiveRecord::Base`.")
264-
owner_to_pool_manager[Base.name]
265-
end
254+
owner_to_pool_manager[owner]
266255
end
267256

268257
# Returns an instance of PoolConfig for a given adapter.

activerecord/test/cases/connection_adapters/connection_handler_test.rb

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -103,20 +103,6 @@ def test_establish_connection_with_primary_works_without_deprecation
103103
ActiveRecord::Base.configurations = old_config
104104
end
105105

106-
def test_retrieve_connection_shows_primary_deprecation_warning_when_established_on_active_record_base
107-
old_config = ActiveRecord::Base.configurations
108-
config = { "primary" => { "adapter" => "sqlite3", "database" => "test/db/primary.sqlite3" } }
109-
ActiveRecord::Base.configurations = config
110-
111-
ActiveRecord::Base.establish_connection(:primary)
112-
113-
assert_deprecated { @handler.retrieve_connection("primary") }
114-
assert_deprecated { @handler.remove_connection_pool("primary") }
115-
ensure
116-
ActiveRecord::Base.configurations = old_config
117-
ActiveRecord::Base.establish_connection(:arunit)
118-
end
119-
120106
def test_establish_connection_using_3_level_config_defaults_to_default_env_primary_db
121107
previous_env, ENV["RAILS_ENV"] = ENV["RAILS_ENV"], "default_env"
122108

guides/source/7_0_release_notes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ Please refer to the [Changelog][active-record] for detailed changes.
116116
attribute :column, :string
117117
```
118118

119+
* Remove deprecacated support to resolve connection using `"primary"` as connection specification name.
120+
119121
### Deprecations
120122

121123
### Notable changes

0 commit comments

Comments
 (0)