mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
The TopologicalSort reverts the order of persisted entities #7244
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 @netbull on GitHub (Nov 11, 2023).
Bug Report
This was reported by #10897 and #10864, but the order is reversed when the nodes are also edges.
Summary
Use case:
Entity Booking and Entity Guest.
If we persist 3 Guests to existing Booking then we have the correct order of the guests as here its used
array_reversebecause herearray_unshiftis used.Current behavior
if we persist new Booking with the same collection of Guests the collection is reversed, because the Guest nodes are also edges to Entity Booking.
How to reproduce
Persist 3 Guest Entities A, B and C and the order will be kept.
Persist new Booking Entity with 3 Guest Entities and the order of the guests will be C, B and A
Expected behavior
The edges array should be also reversed while iterating, the same way as the nodes.
@derrabus commented on GitHub (Nov 11, 2023):
We don't guarantee any order in which entities are being persited. Please elaborate why you believe the current behavior to be defective.
@netbull commented on GitHub (Nov 11, 2023):
@derrabus this says it all basically.
If we try to keep the order the same when the entities are added as nodes, then we should try keeping the order also if they are also edges.
@mpdude commented on GitHub (Nov 12, 2023):
#11058 has more elaborate discussion on the potential requirements or expectations
@derrabus commented on GitHub (Nov 14, 2023):
Let's close this issue then. The behavior described here is not a bug.
We can continue to discuss on #11058 whether we want to change the current behavior or not.