-
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.5] "loadMissing" reload relation when loading nested relations #23027
Comments
I should probably create another issue for this other problem but I've another problem with "load" : Exemple :
After the last load, "myModel->relation" will only have "subRelation-B" loaded, the key "subRelation-A" of myModel->relation doesn't even exists. |
To solve your second problem, you have to combine them into one call:
|
Okay, I confirm @staudenmeir that loading the 2 relations at the same time with one load will load correctly the 2 relations. The problem with this is I cannot ensure I will need the second sub relation right now ! A basic example is : Retrieve "Thing" from database
If I use If I use On an application under heavy load (like an massively used API), I can't afford the cost of a useless DB and lot of PHP calls. Hope you understand my point of view and why loading all the sub-relations ASAP is not feasible. |
I took a look at the You can load the second subrelation like this:
|
I proposed |
Description:
Hi !
I'd like to demonstrate an issue I have with loadMissing and nested relation.
The problem is pretty easy to reproduce so I doubt you are unaware of this but I can't find a workaround nor another issue here.
If you load a relation "inscriptions" and then loadMissing a nested relation of "inscriptions", it will reload the relation "inscriptions".
See below...
Steps To Reproduce:
Load a first time a relation using load or loadMissing :
Here the relation "inscriptions" is correctly loaded and set on the User object.
Then load a nested relation of the first model passing by a relation already loaded :
Here the user object already has the relation "inscriptions" but another query will hit the DB because the relation "inscriptions.formation" is not loaded as it is not really a relation but a composition of a relation and a nested relation.
Edit : To go further, is somewhere in my application I have this :
In this case, the "relation" and "subRelation" will be reloaded.
Is it going to be fixed by somehow checking the relations one by one for every level of nesting ?
Or is it too complicated and I should find a workaround ?
Thanks for your help ! 😄
The text was updated successfully, but these errors were encountered: