-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[Tree] [materializedPath] Deleting parent removes children when onDelete="restrict" #2776
Comments
IIRC the It does look like right now it's known the ORM might not work as expected with So I don't think we have an actionable bug within this package at the moment, if something changes in the ORM around this situation then things can be updated here if need be. |
It seems there might be some confusion here. While it's true that JoinColumn::$onDelete primarily configures the behavior of the foreign key column in the database, its impact extends beyond that. In MySQL, onDelete="restrict" should enforce that a referenced row cannot be deleted while it's still referenced by another table. However, if this isn't being reflected as expected in the ORM, it could indeed be considered a bug. While the ORM may currently handle onDelete="cascade" and "set null" appropriately, the fact that onDelete="restrict" isn't behaving as anticipated could signify a bug. The reported behavior should ideally align with database behavior for consistency and predictability. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
For me it's a bug, Without Tree : we have fatal postgresql error |
In all fairness, I do agree there is a bug here. But, IMO, that bug exists because the ORM itself also doesn't support |
When onDelete="restrict", I don't know if this is the expected behaviour, but deleting the parent also deletes the children. I assumed I would get an SQL error, and the children are still in the database.
Example Entity
Example of PHP Code
With this code I no longer get fatal postgresql error,
$category1
and$category2
deleted even though parent is set to restrict delete.Searching through the code, I found the function that I think is broken :
Here we delete all the children. We do not check if the parent is set to restrict delete.
The text was updated successfully, but these errors were encountered: