New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DDC-1925: Bug in UnitOfWork and ManyToMany relations #2594
Comments
Comment created by @Ocramius: What is the part you commented out? Also, in what context is your code executed? |
Comment created by zhil: I got error when $em->persist($forum); $em->flush(); executed. I can create github repository with code, which reproduce this error, if you want. |
Comment created by @Ocramius: Please do |
Comment created by zhil: that would be simple symfony2 application - will it work for you? |
Comment created by @Ocramius: As long as the code is related to doctrine. Otherwise this issue is quite incomplete :) |
Comment created by zhil: Done, please check https://github.com/zhil/testDoctrine In few words, when I add code like before $em->persist(); $em->flush(); I got fake MYSQL error :) Thank in advance for your help :) |
Comment created by zhil: Just wonder - is it bug in doctrine2 or its problems somewhere else? (symfony2/my code/ etc.) This is part of the live project - I need to fix it :) |
Comment created by @Ocramius: I think it is related with the fact that you're using the |
Comment created by zhil: Well, I used UnitOfWork, because I need to know what was changed during object validation (for example, property status can be changed only in predefined cases etc.). Ok, thanks for the suggestion - I will implement some temporary solution for this problem :) |
Comment created by @Ocramius: I think I spotted where this happens, but I don't have a clear overview on the situation. Will try to work on this... |
Comment created by zhil: Thanks for the checking this issue. entity { and validator if(($object->previousStatusBugfix != -1) && ($object->previousStatusBugfix != $object->getStatus())) { :) |
Comment created by @Ocramius: I just wrote a couple of tests (attaching them to the issue shortly) and found out that on Now looking if it can be merged into |
Issue was closed with resolution "Fixed" |
Comment created by @doctrinebot: A related Github Pull-Request [GH-402] was closed: |
Comment created by @doctrinebot: A related Github Pull-Request [GH-403] was closed: |
Jira issue originally created by user zhil:
Lets say, I have entity Forum with ManyToMany relations with User.
I need to validate user changes and I use code like
$uow = $this->getDoctrine()->getEntityManager()->getUnitOfWork();
$uow->computeChangeSets();
$changeSet = $uow->getEntityChangeSet($forum);
if (.... bla-bla-bla....) {
$em = $this->getDoctrine()->getEntityManager();
$em->persist($forum);
$em->flush();
}
Unfortunately, whenever I try to change manyToMany relations - I got error
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '4-4' for key 'PRIMARY'
If I comment uow code - everything works just great.
It looks like bug in UnitOfWork implementation.
Let me know if you need more details from me.
The text was updated successfully, but these errors were encountered: