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-2524: Wrong commit order with cascade remove and double association #3247
Comments
Comment created by valentin: Here a link to the pull request #707 |
Comment created by mnapoli: The tests on Travis are failing as expected. https://travis-ci.org/doctrine/doctrine2/builds/8382962 Here is the list of the queries executed for MySQL:
As you can see, the latest query causes a foreign key constraint violation (wrong order with the next, non-executed query). |
Comment created by mnapoli: On the sqlite tests we can see better the order the queries are executed:
13 and 14 are in the wrong order. |
Comment created by @guilhermeblanco: This situation is not supported and cannot be resolved within current Doctrine code. Because of that, I'mm marking this ticket as "can't fix". |
Comment created by mnapoli: [~guilhermeblanco] I see what you mean, but the case we submitted is with a nullable foreign key. So the operation is permitted by the RDBMS. A has one B (nullable oneToOne), and B has a pointer to A (manyToOne, not nullable). As I said for the query log, B should be removed first, which is not the case (see above, line 13 and 14 should be inversed). So this is fixable on the Doctrine side if I'm not mistaken. |
Comment created by mnapoli: Just for clarity (I answered this question in the pull request): no this is not fixed (see #707 (comment)). |
Comment created by benjamin: Just encountered what I believe to be the same bug, without any kind of circular dependency:
The following operations in
Result in the following SQL commands:
This is always the wrong commit order, and is doomed to fail when you have unique constraints in the B table. |
Comment created by makm: Another situation without circular dependency:
Why we can't invoke entity deletions method (executeDeletions, UnitOfWork#commit) before executeInserts? |
Comment created by @doctrinebot: |
Comment created by @doctrinebot: |
Issue was closed with resolution "Fixed" |
Jira issue originally created by user mnapoli:
We have stumbled upon a bug in a situation where a class A has the following associations to a class B:
Associations are with cascade remove.
We will submit a PR soon with a failing test case.
The failure is a MySQL foreign key violation exception when removing A (removals for B are executed after removals for A).
The text was updated successfully, but these errors were encountered: