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
How to delete associated is not clear #8348
Comments
do you use |
Enabling I'm not really clear on what the 'problem' here is. Did you find the documentation unclear? Or did you have an issue with records not being deleted? |
As I explain in my post, the doc says:
So for me, cascade means that the operation will be done up to the last level. So we should understand that if I declare:
And then:
Deleting It's difficult to understand why And the word It's because the doc is not really clear. And we could wonder if |
Ah ok. The docs on
Cascading through all associations would require knowing that there was deeper data to be deleted, which requires that data to be loaded. The current behavior of dependent avoids loading related data.
While we can't remove the current option, we can add an alias that better describes the behavior. Do you have a suggestion on a better name? |
But with I can understand that you can't remove an existing option but 'dependent' is really understandable and I wonder if its current behavior is not dangerous enough to not consider to change it. We currently don't ensure DB integrity because we let orpheans and I really don't see a situation where this behavior could be expected. |
No we don't. The associations that support dependent deletes simply emits a deleteAll.
The issue with cascading down to lower levels, is that it can dramatically change the performance characteristics of an application. In order to cascade down each level, we first need to load all the data, and then delete it. I agree that the orphan issue is not ideal, which is why we also provide If you truly want to avoid orphans, databases also offer cascading deletes in constraint definitions, which is the approach I would take if I wanted to be absolutely sure there would never be orphans. |
Ok, why not, but the developper should guess the job impacted by cascading deletes and should know if it could result in thousands of individual deletes. |
I don't think deferred jobs is within the ORM's scope, but I might be misunderstanding you. |
You are perfectly right, it's not what I wanted to say. I just mean that I think that ORM must ensure DB integrity but that should cause long job, particularly in the case we are talking about. So, in that case, I just rely on the doc about
But basically, I just want to say that specifying |
I'm hesitant to change the semantics of existing options as historically that has resulted in a number of upset users and bug reports. I think the documentation updates that have been done are the best option we have outside of adding more options. |
Hello,
So we discussed already how to delete everything when I delete a But now if want to delete one of the So I think that cascading delete are problematic as it only work`s from the top level and no from intermediate levels. Why? |
I spent few hours to try to understand why I couldn't delete correctly my entities (Thanks ndm, Jose)
I wanted to delete an entity and its 2 associated levels.
So I declared my hasOne/hasMany with
dependent
because the doc says:Cool, but that doesn't work.
Thanks to ndm and jose, I understood that
cascadeCallbacks
is needed to delete subsequent levels. ?!?About
cascadeCallbacks
, the doc says:And:
So nothing related to delete associated of 2nd level and so !?!
I think there is a real problem on that point. I don't really understand why
cascadeCallbacks
is for butdependent
should be THE flag to permit to delete all associated levels no?Regards,
Al
The text was updated successfully, but these errors were encountered: