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

[6.x] Set relation connection on eager loaded MorphTo #32602

Merged
merged 1 commit into from
Apr 30, 2020
Merged

[6.x] Set relation connection on eager loaded MorphTo #32602

merged 1 commit into from
Apr 30, 2020

Conversation

yaim
Copy link
Contributor

@yaim yaim commented Apr 29, 2020

As a fix of bug described in issue #29935, this will pass the initial model's connection to the eager loaded MorphTo model that is using a default connection.

@taylorotwell taylorotwell merged commit 2dc1ca2 into laravel:6.x Apr 30, 2020
@yaim yaim deleted the 6.x branch April 30, 2020 01:17
@GrahamCampbell GrahamCampbell changed the title Set relation connection on eager loaded MorphTo [6.x] Set relation connection on eager loaded MorphTo Apr 30, 2020
@Vercoutere
Copy link

Vercoutere commented Jun 4, 2020

@yaim

This appears to be a potentially breaking change for some applications.

Eager loading a morphTo relationship on a model that is being queried without global scopes, appears to apply global scopes anyway because of the call to $this->getConnection().

If I understand what's happening correctly, calling withoutGlobalScopes() on the morphTo relation seems to fix this issue for now.
I don't know what happens if the child in the morphTo relation were to have it's own global scopes applied, which you wouldn't want removed, so I'm not sure if this is the best course of action.

Let me know if you feel I should create an issue for this.

Tagging @PollieDev as he's been working with me on this issue.

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.

3 participants