You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
IIRC the JoinColumn::$onDelete config is only used to configure the foreign key column in the database, the ORM doesn't use that to make any decisions about mapping relationships. Actually, the only place I can find the ORM using that information is in the UnitOfWork when it is determining the order of operations for DELETE statements, and it only takes into consideration "cascade" and "set null".
It does look like right now it's known the ORM might not work as expected with onDelete="restrict", see doctrine/orm#10783 for that.
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.
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: