mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-3134: Inconsistent defaults for onDelete when defining many-to-many relations #3886
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (May 23, 2014).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user adlpz:
When defining a relation with the following annotation:
The following SQL is generated for the foreign key constraints:
As it can be seen, the default seems to be to include ON DELETE CASCADE. This feels like a dangerous behaviour (and I couldn't find it documented), but fair enough. The inconsistency comes when adding:
In this case, even if we are not providing any values for the join and inverse join columns, we get:
As it can be seen, the ON DELETE CASCADE is gone.
I understand this is the case because, when giving empty JoinColumn annotations it's not the engine defaults that are processed, but the inferred values for the annotation. Still, this seems to be either a bug or an undocumented behaviour.
Am I doing anything wrong here? Should this be looked into?