mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Orphan removal is executed after resultingIntegrity constraint violation when re-adding a new item with the same code
#6503
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 @mynameisbogdan on GitHub (Jul 12, 2020).
Bug Report
Summary
When removing an item with a unique code index from a OneToMany relationship and re-adding a new item with the some code it will result into a
SQLSTATE[23000]: Integrity constraint violation: 19 UNIQUE constraint failedCurrent behavior
How to reproduce
Expected behavior
In this case maybe orphan removal should be executed first and then insert the new data.
@nescim commented on GitHub (Nov 25, 2020):
I had a similar, probably related, issue where the FK column in the related entity is not nullable.
Attempts to rely on orphan removal result in an error because the FK column is being set to
NULLrather than the row beingDELETEd altogether.