mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Multiple composite foreign keys sharing a common column #6968
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 @theoaks on GitHub (Apr 27, 2022).
Bug Report
Summary
I have a table having multiple composite foreign key references to the same table. All the foreign key references have a single column they share together.
Table1
ID(PK)
TableA:
ColA (PK1, FK[Table1(ID)])
ColB (PK2)
TableB:
ID(PK)
Table1ID(FK[Table1(ID)])
Col1 (FK[TableA(ColA = Table1ID, ColB)])
Col2 (FK[TableA(ColA = Table1ID, ColB)])
Col3 (FK[TableA(ColA = Table1ID, ColB)])
Current behavior
When any of $TableB::$tableA1, TableB::$tableA2 or TableB::$tableA3 is set to null, column (Table1ID on TableB) is set to null while the other columns (Col1, Col2 or Col3 on TableB) retain their values. This breaks the composite foreign key.
How to reproduce
Expected behavior
Setting any of TableB::$tableA1, TableB::$tableA2, TableB::$tableA3 to null shouldn't affect the shared composite foreign key column