mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-555: @ManyToMany - curious behaviour - assigned values toggle #688
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 (Apr 29, 2010).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user jellobird:
BUG:
the entries in M:N table article_categories toggle
SOLUTION:
extra flush entry at [*]
Code:
Entities:
tried to apply cascade={"all"}, but has no effect.
@doctrinebot commented on GitHub (Apr 29, 2010):
Comment created by @beberlei:
I dont understand this issue, can you please elaborate what exactly is wrong?
@doctrinebot commented on GitHub (Apr 30, 2010):
Comment created by jellobird:
To be more verbose:
I have two tables article and category.
These tables are connected via a m:n-relationship with table article_category.
You can see the entity configuration snippets within the code Entities.
To reconstruct this bug, set up your database with these 3 tables. Put in some data, but keep the table article_category empty.
Now, with an properly configured entity manager, you can execute the displayed code.
There is a line {quote}printf("-- %s\n", count($article->getCategories()));{quote} which shows the number of categories connected with one article.
Please adjust array(4) to use valid category primary keys.
You will notice, as a result of this script, that sequential uses will produce
with n the number of categories you add. it will be 1 in this example (see: array(4))
If you check the database between the runs, you will notice that the table article_categories is filled, empty, filled, empty, filled, ... corresponding to the script results.
SOLUTION: You can solve this with one extra line:
$em->flush(); // [*]I think the described behavior is not intended.
@doctrinebot commented on GitHub (Jul 1, 2010):
Comment created by @beberlei:
The problem is that clear() is actually scheduling the deletion of the whole colleciton. This is a completly different operation compared to:
If you do it this way and than re-add some of the objects, those associations will not be changed.
clear() however deletes all, then adds the new ones. again
@doctrinebot commented on GitHub (Jul 3, 2010):
Comment created by @beberlei:
Verified as a bug though.
@doctrinebot commented on GitHub (Jul 3, 2010):
Comment created by jellobird:
I see.
I suggest an additional method:
http://www.doctrine-project.org/jira/browse/DDC-665
@doctrinebot commented on GitHub (Jul 3, 2010):
Comment created by @beberlei:
Not necessary, this was actually a bug. It should be fixed in the current master.
@doctrinebot commented on GitHub (Jul 3, 2010):
Issue was closed with resolution "Fixed"