Skip to content
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

Through scope should not be affected by scoping #30271

Conversation

kamipo
Copy link
Member

@kamipo kamipo commented Aug 15, 2017

Follow up of #29834.

Fixes #30266.

@rafaelfranca rafaelfranca merged commit 979277d into rails:master Aug 15, 2017
@kamipo kamipo deleted the through_scope_should_not_be_affected_by_scoping branch August 15, 2017 19:53
rafaelfranca added a commit that referenced this pull request Aug 15, 2017
…ected_by_scoping

Through scope should not be affected by scoping
rafaelfranca added a commit that referenced this pull request Aug 15, 2017
…ected_by_scoping

Through scope should not be affected by scoping
kamipo added a commit to kamipo/rails that referenced this pull request Apr 5, 2019
Follow-up of 5c71000, rails#29834, and rails#30271.

Currently, preloading and eager loading are not to be affected by
scoping, with the exception of `unscoped`.

But non eager loaded association access is still affected by scoping.

Although this is a breaking change, the association loading will work
consistently whether preloaded / eager loaded or not.

Before:

```ruby
Post.where("1=0").scoping do
  Comment.find(1).post                   # => nil
  Comment.preload(:post).find(1).post    # => #<Post id: 1, ...>
  Comment.eager_load(:post).find(1).post # => #<Post id: 1, ...>
end
```

After:

```ruby
Post.where("1=0").scoping do
  Comment.find(1).post                   # => #<Post id: 1, ...>
  Comment.preload(:post).find(1).post    # => #<Post id: 1, ...>
  Comment.eager_load(:post).find(1).post # => #<Post id: 1, ...>
end
```

Fixes rails#34638.
Fixes rails#35398.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants