-
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
Polymorphic eager loading with select not working (correctly) #2966
Comments
We don't currently support limiting the selects on those relations because if it's not done properly it can break the query. You can remove the columns once the data has been retrieved if you like. |
is it still an issue? or is there support for such things now? |
Is there any way to set visible hidden properties on the relation directly then? |
This has been fixed in Laravel 5.7.6 (#25662). |
Hello, #25662 introduce a bug, work :
don't work :
if you have an idea, thanks. |
ping to @staudenmeir |
@acacha Why? |
@acacha if the ping is because of my post, it has been resolved. the precise syntax we were using was :
without the id (contrary to what i said earlier) Since 5.7.6, the select clause is applied, it was not the case in 5.7.5. |
I have three tables, 'actors', 'series' and 'movies'. An actor can belong to many series and/or many movies, and both movies and series can have many actors. Good case for a polymorphic many-to-many relationship.
When I query all movies, I wish to eager load all actors, but only their first and last names. For this I do the following:
This however still loads ALL columns for actors, since the resulting query is this one:
The issue here, is that the columns I requested (first_name and last_name) are indeed inserted into the query (first two fields), but then the
actors
.*` is automatically added, which obviously loads the rest of the columns as well.I'm not smart enough to figure out how Laravel actually builds this query, so I'm not at all able to contribute with a pull request. Sorry.
The text was updated successfully, but these errors were encountered: