mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
[PR #10531] Add test: Commit order calculation must happen on the entity level #12434
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?
Original Pull Request: https://github.com/doctrine/orm/pull/10531
State: closed
Merged: Yes
Add tests for entity insertion and deletion that require the commit order calculation to happen on the entity level. This demonstrates the necessity for the changes in #10547.
This PR contains two tests with carefully constructed entity relationships, where we have a non-nullable
parentforeign key relationships between entities stored in the same table.Class diagram:
Object graph:
Situation before #10547
The commit order is computed by looking at the associations at the table (= class) level. Once the ordering of tables has been found, entities being mapped to the same table will be processed in the order they were given to
persist()orremove().That means only a particular ordering of
persist()orremove()calls (see comment in the test) works:For inserts, the order must be
$a, $b2, $b1, $b3(or... $b3, $b1), for deletions$b1, $b3, $b2, $a.Situation with entity-level commit order computation (as in #10547)
The ORM computes the commit order by considering associations at the entity level. It will be able to find a working order by itself.