-
由 eileencodes 提交于
While working on some more indepth changes to Rails internal connection management we noticed that it's confusing in some cases that the `role` is implcit when using a `shard`. For example, if you passed a `shard` and not a `role` in an un-nested block the default `role` would be `writing`. ``` ActiveRecord::Base.connected_to(shard: :one) do # connected to writing end ``` However in cases where nesting is used it could be confusing to application authors that the role is inherited: ``` ActiveRecord::Base.connected_to(role: :reading) do ActiveRecord::Base.connected_to(shard: :one) do # will read from shard one replica, not write to primary end end ``` Since this could be potentially confusing, and extremely hard to track in complex applications, the best approach is to require `role` when using `shard` which is what this PR does. Note: the code for this method is...getting unweildy. Once the `database` argument is fully deprecated we can remove most of the guards and make `role` required by removing `nil` from the keyword argument. Until then we need to support required arguments in this round about way.
d4df616c