mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
DDC-1662: oprhanRemoval=true vs casdade={remove} for OneToMany relationships #2088
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 (Feb 21, 2012).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user juokaz:
Client has a data structure like PhoneBook->Address[]. PhoneBook has many addresses.
They have expectations as:
Removing address from collection removes the address entity
Deleting phonebook checks if there are addresses and if there are constrain should fail
In code:
first case
second case
Adding orphanRemoval = true, makes first case work, but also implicitly defines cascade={remove} for second case, as all addresses are then removed on phonebook remove.
It looks to me like a feature (or design idea) rather than a bug. Any comments?
@doctrinebot commented on GitHub (Feb 21, 2012):
Comment created by @beberlei:
The second case is domain logic, not something that doctrine/database should enforce. You can add a preRemove check to fail if a phonebook contains addresses.
@doctrinebot commented on GitHub (Feb 21, 2012):
Issue was closed with resolution "Invalid"
@doctrinebot commented on GitHub (Feb 21, 2012):
Comment created by @beberlei:
That means yes, orphanRemoval=true should be set here, and the second case should be checked in the domain of the project.