mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-978: Many-To-Many relations are removed after Flush() #1217
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 (Jan 12, 2011).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user slasher:
Let's say we have three entities: User, Channel, and Log
Every time a User is created or updated, Channels are assigned to a Many-To-Many collection.
This action gets logged in the Log entity.
I have reproduced the bug in the Doctrine sandbox (see attachment). It's a fully working example.
This is a summary:
This last piece of code generates following SQL code (summarized):
If you remove the $em->flush() after $em->persist($user); in the last example, the code works (channels are persisted).
I did not have this problem with Doctrine2 Alpha4.
@doctrinebot commented on GitHub (Jan 12, 2011):
@doctrinebot commented on GitHub (Jan 12, 2011):
Comment created by @beberlei:
What do you do in "setChannels"? Do you completly overwrite the previous content of the association variable "User::$channels" ?
@doctrinebot commented on GitHub (Jan 12, 2011):
Comment created by slasher:
I have reproduced the bug in a fully working example. See attachment. Just read instructions in comment and execute each step seperately.
But yes, I overwrite the previous content of the association variable "User::$channels" with a Doctrine ArrayCollection.
\
@doctrinebot commented on GitHub (Jan 23, 2011):
Comment created by @beberlei:
Fixed.
@doctrinebot commented on GitHub (Jan 23, 2011):
Issue was closed with resolution "Fixed"