module ActiveRecord::ConnectionHandling

def connecting_to(role: default_role, shard: default_shard, prevent_writes: false)

does not yield to a block like +connected_to+.
It is not recommended to use this method in a request since it

being used. For example, when booting a console in readonly mode.
This method is useful for ensuring that a specific connection is

Use a specified connection.
def connecting_to(role: default_role, shard: default_shard, prevent_writes: false)
  prevent_writes = true if role == ActiveRecord.reading_role
  append_to_connected_to_stack(role: role, shard: shard, prevent_writes: prevent_writes, klasses: [self])
end