Custom remove function wrapper to ensure that all orphanRemoval-relations are populated #5298
Jcalcaldev
started this conversation in
Ideas
Replies: 2 comments
-
I think it would make more sense to load the relation automatically, we could make that opt out and throw in such case, then it wont be breaking anyhow. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Sounds good, any way to make sure that all orphanRemovals go as expected any time without requiring developers to remember every time what to populate, same as cascades would in the database level |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is your feature request related to a problem? Please describe.
On another thread I was made to realize that orphanRemoval doesn't work if relations are not populated, this might be a problem and devs might forget to populate deeply nested relations in some cases.
Describe the solution you'd like
I've already implemented a partial solution that seems to work. Basically, upon remove, it checks if all of the entitiy(es) to remove have orphanRemoval-marked relations and forces them to be populated or throws an error. It works on 1:m and 1:1 relations as far as I know.
Here's the proposed solution:
A possible improvement for the ORM would be for the remove to take an optional argument to run a check of these sorts behind the scenes.
Describe alternatives you've considered
Custom solution up above
Additional context
Nope
Beta Was this translation helpful? Give feedback.
All reactions