mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-158: Removing relation in many-to-many association #198
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 (Nov 19, 2009).
Jira issue originally created by user alex:
I have 2 entities. Users and Roles. The user entity has a many-to-many relation with roles.
Removing a relation between a user and a role does not work.
Expected: the first role of the first set does not exist in the second set
Actual:
@doctrinebot commented on GitHub (Nov 19, 2009):
Comment created by alex:
Addition:
Removing a role from the user->roles collection does result in one less role. Only the persistence of this removal is not told to the database.
@doctrinebot commented on GitHub (Nov 19, 2009):
Comment created by romanb:
Can you attach or paste the User and Role classes with their mappings? That will make it easier to reproduce your case and also to integrate it into the test suite later when the issue is solved.
@doctrinebot commented on GitHub (Nov 19, 2009):
Comment created by romanb:
I'm on it.
@doctrinebot commented on GitHub (Nov 19, 2009):
Comment created by alex:
Added User and Role mappings. Should be enough to recreate the classes and db tables
@doctrinebot commented on GitHub (Nov 19, 2009):
Comment created by romanb:
Finally someone who uses xml mappings (my personal preference) :) If you encounter any issues with the xml metadata driver, because its the least frequently used, dont hesitate to open tickets and they will be addressed as soon as possible.
This issue should be fixed now. See the corresponding changeset. I recreated the issue in our test suite with a many-to-many user-groups association and your test code.
The problem was related to collections not properly taking a snapshot of their state after lazy initialization which caused the wrong change sets during flush.
By the way, you dont need to call persist($user) after changing the associated collection when using the default change tracking policy (DEFERRED_IMPLICIT). Only flush() should be enough.
Thanks for reporting. If you dont see this issue solved please reopen with any new information.
@doctrinebot commented on GitHub (Nov 19, 2009):
Issue was closed with resolution "Fixed"
@doctrinebot commented on GitHub (Nov 19, 2009):
Comment created by alex:
Tried to use annotations, took me an hour to neatly convert my xml. When I was almost finished a looked at my classes and quickly reverted everything.. Yak!
I'm still at the beginning of my project so haven't used much of DC2. Will keep an eye out for any XMl driver related issues (or other).
Thanks for the quick response and commit.
Tested it with my own code and it works as it is expected.
@doctrinebot commented on GitHub (Dec 13, 2015):
Imported 2 attachments from Jira into https://gist.github.com/522fa631513209771091