-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
oneToMany orphanRemoval with unique - constraint violation #6776
Comments
@akomm thanks for reporting the issue, we do need a test though (we're also short on time). Send us something when you're available and we discuss on the PR. |
I resolved the #6738 issue but could not make a reproduction "quick" and worked around it removing the unique constraint temporary relying on code as long as the app is not in prod. Want to return to the reproduction test when rest is done, so I can enable the constraint again. |
Hi, |
@julienb-allopneus could you please send us a failing test case that reproduces that behaviour? It would help us a lot to identify and fix the issue you're describing. You can find examples on https://github.com/doctrine/doctrine2/tree/388afb46d0cb3ed0c51332e8df0de9e942c2690b/tests/Doctrine/Tests/ORM/Functional/Ticket |
Hi @lcobucci , |
I have written a test in the following PR #6838 , please have a look and tell me what's next :-) Thanks, Julien. |
Hi all, Any news/advice on the test I wrote? Thanks, Julien. |
I'm having this same issue on a OnToOne relationship as well (no matter which the owning side it). Is this related to this issue, or is there some other documentation someone can point me at? |
@toby we'd need a test case to verify that.
…On 6 Mar 2018 18:38, "Toby Griffiths" ***@***.***> wrote:
I'm having this same issue on a OnToOne relationship as well (no matter
which the owning side it).
Is this related to this issue, or is there some other documentation
someone can point me at?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#6776 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAJakO86kAhc5wRGz95LNkqfQUwTU-acks5tbsl4gaJpZM4P6XxY>
.
|
@Ocramius @toby-griffiths we do have a test case in #6838 - it needs to be updated, sure |
@Ocramius Should I add my case details here, or raise a new ticket? |
Or Raise a new Test Case, as per @lcobucci 's comment? |
(Thanks for the prompt reply, btw) |
@toby-griffiths yeah, you'd need to send a PR against that fork |
OK. Will do when I can find a moment. |
Any updates on this issue? |
Please advise if this PR needs modifying (& how) as I was unable to submit the PR to the |
Is this still being worked on? I am a bit lost about the status here, but this bug is quiet annoying. |
Failing tests were added and a bugfix PR is needed to make the tests work. |
I'm also facing this bug and it's quite annoying. |
@vincentbab seems like they don't want to fix that. I am olso faced with that issue and trying to find workaround |
@sannek8552 can't blame them, they do it in their free time, there is no paid core team supported by some company AFAIK, like in many other OOS projects. |
I'm also facing with this :( |
This is a long standing bug that should have an even older ticket (I remember it was open during 2.0 beta already). The problem is that we couldn't re-order insert after deletes for some other reason that I forgot at the moment. |
I had a similar use case. I think it's better to handle it manually, until Doctrine is able to handle this more gracefully. This method prevents deletes/inserts when an update will do the job also.
Example dealing with currencies:
|
Since nobody posted it, here you go. This issue is related to #5109 and you should be aware of the long discussion there. |
Unique constraint currently breaks due to a wrong order in the unit of work, see for example: doctrine/orm#6776
There are a few requests (doctrine#5742, doctrine#5368, doctrine#5109, doctrine#6776) that ask to change the order of operations in the UnitOfWork to perform "deletes before inserts", or where such a switch appears to solve a reported problem. I don't want to say that this is not doable. But this PR at least adds two tricky examples where INSERTs need to be done before an UPDATE can refer to new database rows; and where the UPDATE needs to happen to release foreign key references to other entities before those can be DELETEd. So, at least as long as all operations of a certain type are to be executed in blocks, this example allows no other order of operations than the current one.
It seems that having the DELETEs before the INSERTs would be a fix for this case. But, #10809 adds two examples that show why this cannot easily be done, at least not in general. |
There are a few requests (doctrine#5742, doctrine#5368, doctrine#5109, doctrine#6776) that ask to change the order of operations in the UnitOfWork to perform "deletes before inserts", or where such a switch appears to solve a reported problem. I don't want to say that this is not doable. But this PR at least adds two tricky examples where INSERTs need to be done before an UPDATE can refer to new database rows; and where the UPDATE needs to happen to release foreign key references to other entities before those can be DELETEd. So, at least as long as all operations of a certain type are to be executed in blocks, this example allows no other order of operations than the current one.
I have found only one fix for this extremely annoying issue that took me many tries and several hours to work around, and that is, that I have to manually filter out removed orphans BEFORE adding new ones or updating existing ones, AND I have to flush the removed ones too:
Personally I would suggest adding a flag to the |
I currently do not have time for the test, also because this blocks me: #6738. I try to add one asap.
Issue is the following:
Preconditions:
You do the following in a single transaction/flush:
When the column value (unique constraint) on the removed entities (1) equals the column value (unique constraint) on the created entities (2) a constraint violation is raised.
Reason:
The created entities (2) are INSERTed before the removed entities (1) are DELETEd.
Found a fixed, similar issue, just ManyToMany: #2310
The text was updated successfully, but these errors were encountered: