active_record_shards
active_record_shards copied to clipboard
Raise when calling connection on a sharded model without a shard
/cc @bquorning @grosser @kassio @craig-day
When calling Model.connection
on a sharded model when we're not on a shard returns a connection to the unsharded database. This PR fixes the issue by raising when trying to call connection
without specifying a shard.
fyi @jacobat
How does this play with #130?
@jacobat I would assume your PR would be fine. Our issue in Classic is some code paths relying on default_shard
to be set, but it's actually nil
. Removing default_shard
would probably raise the same way it does here.