未验证 提交 685683fd 编写于 作者: E Eileen M. Uchitelle 提交者: GitHub

Merge pull request #40017 from eileencodes/fix-missed-handler-method

Fix missed establish_connection
......@@ -49,7 +49,7 @@ module ConnectionHandling
def establish_connection(config_or_env = nil)
config_or_env ||= DEFAULT_ENV.call.to_sym
db_config, owner_name = resolve_config_for_connection(config_or_env)
connection_handler.establish_connection(db_config, owner_name: owner_name, shard: current_shard)
connection_handler.establish_connection(db_config, owner_name: owner_name)
end
# Connects a model to the databases specified. The +database+ keyword
......@@ -89,7 +89,7 @@ def connects_to(database: {}, shards: {})
db_config, owner_name = resolve_config_for_connection(database_key)
handler = lookup_connection_handler(role.to_sym)
connections << handler.establish_connection(db_config, owner_name: owner_name, shard: default_shard)
connections << handler.establish_connection(db_config, owner_name: owner_name)
end
shards.each do |shard, database_keys|
......@@ -154,7 +154,7 @@ def connected_to(database: nil, role: nil, shard: nil, prevent_writes: false, &b
db_config, owner_name = resolve_config_for_connection(database)
handler = lookup_connection_handler(role)
handler.establish_connection(db_config, default_shard, owner_name)
handler.establish_connection(db_config, owner_name: owner_name)
with_handler(role, &blk)
elsif shard
......
......@@ -217,6 +217,14 @@ def test_switching_connections_with_database_and_role_raises
assert_equal "`connected_to` cannot accept a `database` argument with any other arguments.", error.message
end
def test_database_argument_is_deprecated
assert_deprecated do
ActiveRecord::Base.connected_to(database: { writing: { adapter: "sqlite3", database: "test/db/primary.sqlite3" } }) { }
end
ensure
ActiveRecord::Base.establish_connection(:arunit)
end
def test_switching_connections_without_database_and_role_raises
error = assert_raises(ArgumentError) do
ActiveRecord::Base.connected_to { }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册