-
Notifications
You must be signed in to change notification settings - Fork 21.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Relation#transaction
to not apply a default scope
#50395
Merged
Merged
Conversation
This file contains 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
Fix: rails#50368 When called on a scope it would go through the default scoping delegator that applies a default scope, which make no sense.
casperisfine
pushed a commit
to Shopify/rails
that referenced
this pull request
Dec 19, 2023
In rails#50395 I noticed lots of methods are delegated from `Relation` to the model. The intent of this code is to allow using use defined class methods like scopes. But because of this autmated delegation it allowed calling any `ActiveRecord::Base` class method on a `Relation`, which in itself may be desireable, however we very wastefully define the delegator on the first call, and worse we wrap it with a current scope setter. So I think we should be more strict about it.
byroot
added a commit
that referenced
this pull request
Dec 19, 2023
Fix `Relation#transaction` to not apply a default scope
byroot
added a commit
that referenced
this pull request
Dec 19, 2023
Fix `Relation#transaction` to not apply a default scope
Backported to 7-0-stable and 7-1-stable. |
casperisfine
pushed a commit
to Shopify/rails
that referenced
this pull request
Dec 19, 2023
In rails#50395 I noticed lots of methods are delegated from `Relation` to the model. The intent of this code is to allow using use defined class methods like scopes. But because of this autmated delegation it allowed calling any `ActiveRecord::Base` class method on a `Relation`, which in itself may be desireable, however we very wastefully define the delegator on the first call, and worse we wrap it with a current scope setter. So I think we should be more strict about it.
casperisfine
pushed a commit
to Shopify/rails
that referenced
this pull request
Dec 22, 2023
In rails#50395 I noticed lots of methods are delegated from `Relation` to the model. The intent of this code is to allow using use defined class methods like scopes. But because of this autmated delegation it allowed calling any `ActiveRecord::Base` class method on a `Relation`, which in itself may be desireable, however we very wastefully define the delegator on the first call, and worse we wrap it with a current scope setter. So I think we should be more strict about it.
casperisfine
pushed a commit
to Shopify/rails
that referenced
this pull request
Jan 15, 2024
In rails#50395 I noticed lots of methods are delegated from `Relation` to the model. The intent of this code is to allow using use defined class methods like scopes. But because of this autmated delegation it allowed calling any `ActiveRecord::Base` class method on a `Relation`, which in itself may be desireable, however we very wastefully define the delegator on the first call, and worse we wrap it with a current scope setter. So I think we should be more strict about it.
casperisfine
pushed a commit
to Shopify/rails
that referenced
this pull request
May 10, 2024
In rails#50395 I noticed lots of methods are delegated from `Relation` to the model. The intent of this code is to allow using use defined class methods like scopes. But because of this autmated delegation it allowed calling any `ActiveRecord::Base` class method on a `Relation`, which in itself may be desireable, however we very wastefully define the delegator on the first call, and worse we wrap it with a current scope setter. So I think we should be more strict about it.
casperisfine
pushed a commit
to Shopify/rails
that referenced
this pull request
May 10, 2024
In rails#50395 I noticed lots of methods are delegated from `Relation` to the model. The intent of this code is to allow using use defined class methods like scopes. But because of this autmated delegation it allowed calling any `ActiveRecord::Base` class method on a `Relation`, which in itself may be desireable, however we very wastefully define the delegator on the first call, and worse we wrap it with a current scope setter. So I think we should be more strict about it.
casperisfine
pushed a commit
to Shopify/rails
that referenced
this pull request
May 10, 2024
In rails#50395 I noticed lots of methods are delegated from `Relation` to the model. The intent of this code is to allow using use defined class methods like scopes. But because of this autmated delegation it allowed calling any `ActiveRecord::Base` class method on a `Relation`, which in itself may be desireable, however we very wastefully define the delegator on the first call, and worse we wrap it with a current scope setter. So I think we should be more strict about it.
casperisfine
pushed a commit
to Shopify/rails
that referenced
this pull request
May 10, 2024
In rails#50395 I noticed lots of methods are delegated from `Relation` to the model. The intent of this code is to allow using use defined class methods like scopes. But because of this autmated delegation it allowed calling any `ActiveRecord::Base` class method on a `Relation`, which in itself may be desireable, however we very wastefully define the delegator on the first call, and worse we wrap it with a current scope setter. So I think we should be more strict about it.
casperisfine
pushed a commit
to Shopify/rails
that referenced
this pull request
May 13, 2024
In rails#50395 I noticed lots of methods are delegated from `Relation` to the model. The intent of this code is to allow using use defined class methods like scopes. But because of this autmated delegation it allowed calling any `ActiveRecord::Base` class method on a `Relation`, which in itself may be desireable, however we very wastefully define the delegator on the first call, and worse we wrap it with a current scope setter. So I think we should be more strict about it.
casperisfine
pushed a commit
to Shopify/rails
that referenced
this pull request
May 13, 2024
In rails#50395 I noticed lots of methods are delegated from `Relation` to the model. The intent of this code is to allow using use defined class methods like scopes. But because of this autmated delegation it allowed calling any `ActiveRecord::Base` class method on a `Relation`, which in itself may be desireable, however we very wastefully define the delegator on the first call, and worse we wrap it with a current scope setter. So I think we should be more strict about it.
casperisfine
pushed a commit
to Shopify/rails
that referenced
this pull request
May 13, 2024
In rails#50395 I noticed lots of methods are delegated from `Relation` to the model. The intent of this code is to allow using use defined class methods like scopes. But because of this autmated delegation it allowed calling any `ActiveRecord::Base` class method on a `Relation`, which in itself may be desireable, however we very wastefully define the delegator on the first call, and worse we wrap it with a current scope setter. So I think we should be more strict about it.
casperisfine
pushed a commit
to Shopify/rails
that referenced
this pull request
May 13, 2024
In rails#50395 I noticed lots of methods are delegated from `Relation` to the model. The intent of this code is to allow using use defined class methods like scopes. But because of this autmated delegation it allowed calling any `ActiveRecord::Base` class method on a `Relation`, which in itself may be desireable, however we very wastefully define the delegator on the first call, and worse we wrap it with a current scope setter. So I think we should be more strict about it.
casperisfine
pushed a commit
to Shopify/rails
that referenced
this pull request
May 13, 2024
In rails#50395 I noticed lots of methods are delegated from `Relation` to the model. The intent of this code is to allow using use defined class methods like scopes. But because of this autmated delegation it allowed calling any `ActiveRecord::Base` class method on a `Relation`, which in itself may be desireable, however we very wastefully define the delegator on the first call, and worse we wrap it with a current scope setter. So I think we should be more strict about it.
casperisfine
pushed a commit
to Shopify/rails
that referenced
this pull request
May 28, 2024
In rails#50395 I noticed lots of methods are delegated from `Relation` to the model. The intent of this code is to allow using use defined class methods like scopes. But because of this autmated delegation it allows calling any `ActiveRecord::Base` class method on a `Relation`, which in itself may be desireable, however we very wastefully define the delegator on the first call, and worse we wrap it with a global scope setter. This also has led to bugs in the past, like rails#51776 So I think we should be more strict about it. We can't deprecate this behavior because gems might depend on it, however we can ban it from Active Record's own test suite to avoid regressions.
xjunior
pushed a commit
to xjunior/rails
that referenced
this pull request
Jun 9, 2024
In rails#50395 I noticed lots of methods are delegated from `Relation` to the model. The intent of this code is to allow using use defined class methods like scopes. But because of this autmated delegation it allows calling any `ActiveRecord::Base` class method on a `Relation`, which in itself may be desireable, however we very wastefully define the delegator on the first call, and worse we wrap it with a global scope setter. This also has led to bugs in the past, like rails#51776 So I think we should be more strict about it. We can't deprecate this behavior because gems might depend on it, however we can ban it from Active Record's own test suite to avoid regressions.
Set2005
pushed a commit
to Set2005/fix-association-initialize-order
that referenced
this pull request
Jul 8, 2024
In rails#50395 I noticed lots of methods are delegated from `Relation` to the model. The intent of this code is to allow using use defined class methods like scopes. But because of this autmated delegation it allows calling any `ActiveRecord::Base` class method on a `Relation`, which in itself may be desireable, however we very wastefully define the delegator on the first call, and worse we wrap it with a global scope setter. This also has led to bugs in the past, like rails#51776 So I think we should be more strict about it. We can't deprecate this behavior because gems might depend on it, however we can ban it from Active Record's own test suite to avoid regressions.
DanielaVelasquez
pushed a commit
to DanielaVelasquez/rails
that referenced
this pull request
Oct 3, 2024
In rails#50395 I noticed lots of methods are delegated from `Relation` to the model. The intent of this code is to allow using use defined class methods like scopes. But because of this autmated delegation it allows calling any `ActiveRecord::Base` class method on a `Relation`, which in itself may be desireable, however we very wastefully define the delegator on the first call, and worse we wrap it with a global scope setter. This also has led to bugs in the past, like rails#51776 So I think we should be more strict about it. We can't deprecate this behavior because gems might depend on it, however we can ban it from Active Record's own test suite to avoid regressions.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix: #50368
When called on a scope it would go through the default scoping delegator that applies a default scope, which make no sense.