-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[5.6] [WIP] Can't lazy-load polymorphic relationships with different primary key columns #24063
Conversation
Can you include a fix as well? |
I've tried but can't figure one out. The closest I've gotten is I think it's attempting to use the framework/src/Illuminate/Database/Eloquent/Relations/MorphTo.php Lines 119 to 123 in ab02a65
Hopefully someone who better understands this part of the code can provide some insight. |
I would say that the problem originates in
In my test I could solve it by manually forcing the lazy loading into framework/src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php Lines 193 to 195 in ab02a65
But how can we detect lazy loading? The only way I can think of is analyzing the backtrace, which is rather terrible... |
It appears #21310 is when this stopped working. |
I can't really take any action on this PR since it's just a broken test. If someone can contribute a fix that is better. |
@victordzmr @fntneves Could you provide any insight on this? When laravel/ideas#587 was implemented, this functionality broke. |
Since #21310 As a result, |
As per the contribution guide, I'm submitting a bug report in the form of a pull request containing a failing test.
Summary
You cannot lazy-load models of a polymorphic relationship that have different primary key columns.
posts
videos
comments
To run the test(s) for yourself:
As a footnote, I understand that having primary keys like in my example doesn't make a whole lot of sense. However that is not under my control and not something I can change.