active_record_shards icon indicating copy to clipboard operation
active_record_shards copied to clipboard

Raise when calling connection on a sharded model without a shard

Open pschambacher opened this issue 7 years ago • 2 comments

/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

pschambacher avatar Oct 06 '17 22:10 pschambacher

How does this play with #130?

jacobat avatar Oct 09 '17 08:10 jacobat

@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.

pschambacher avatar Oct 09 '17 14:10 pschambacher