Add test to show why delete-before-insert may be challenging#10809
Merged
greg0ire merged 1 commit intoJun 30, 2023
Conversation
This was referenced Jun 28, 2023
greg0ire
previously approved these changes
Jun 28, 2023
| $this->createSchemaForModels( | ||
| GH5742Person::class, | ||
| GH5742Toothbrush::class, | ||
| GH5742ToothpasteBrand::class |
Member
There was a problem hiding this comment.
Aaaah a funny test at last… this is going to be good! 🍿
Contributor
Author
There was a problem hiding this comment.
I designed it that way particularly with you in mind 😉
| $person->preferredBrands->set(1, $oldMice); | ||
| $this->_em->flush(); | ||
|
|
||
| $newSpice = new GH5742ToothpasteBrand(); |
Member
There was a problem hiding this comment.
"old mice"? "new spice" What's the joke? I don't get it… 🤔
Contributor
Author
There was a problem hiding this comment.
Old mice 🐁 is not so yum.
New spice might me something fresh like peppermint?
Member
|
What do we expect when those tests fail? An exception that breaks the tests? |
Contributor
Author
|
Yes, something related to foreign keys, constraint violation and such |
derrabus
reviewed
Jun 29, 2023
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.
0ecf3fe to
e9b6fd8
Compare
SenseException
approved these changes
Jun 29, 2023
Member
|
Thanks @mpdude ! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There are a few requests (#5742, #5368, #5109, #6776, #7721, #7722, #2310) 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.