This repository was archived by the owner on Nov 19, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Raise when calling connection on a sharded model without a shard #131
Open
pschambacher
wants to merge
1
commit into
main
Choose a base branch
from
pschambacher/raise_when_no_shard_on_connection
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0ca6ae7 to
0e16bc7
Compare
bquorning
reviewed
Oct 6, 2017
test/connection_switching_test.rb
Outdated
|
|
||
| if ActiveRecord::VERSION::MAJOR > 3 | ||
| describe "ActiveRecord::Base.connection.schema_cache.columns_hash" do | ||
| before do |
Member
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need a bit more indentation from here and down.
0e16bc7 to
5de0c78
Compare
grosser
reviewed
Oct 7, 2017
| nil | ||
| else | ||
| @shard || self.class.default_shard | ||
| @shard || self.class.default_shard || raise('You can not connect a sharded model without calling on_shard.') |
Contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe next PR should be removing default_shard ;)
grosser
reviewed
Oct 7, 2017
| end | ||
| end | ||
|
|
||
| it 'explodes when a shard has been specified for sharded model' do |
Contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it 'works ...
grosser
approved these changes
Oct 7, 2017
kassio
approved these changes
Oct 9, 2017
Contributor
|
How does this play with #130? |
Contributor
Author
|
@jacobat I would assume your PR would be fine. Our issue in Classic is some code paths relying on |
bquorning
approved these changes
Oct 9, 2017
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
/cc @bquorning @grosser @kassio @craig-day
When calling
Model.connectionon 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 callconnectionwithout specifying a shard.fyi @jacobat