[DDC-1283] Possible issue with PersistentCollection#getDelete/InsertDiff() Created: 21/Jul/11 Updated: 07/Sep/13
|Project:||Doctrine 2 - ORM|
|Reporter:||Glen Ainscow||Assignee:||Guilherme Blanco|
Using the following code, when you go from (1, 2) to (1), (2) is deleted as expected. However, if you go from (1, 2) to (2), (1) and (2) are deleted and (2) is then inserted. Is this the desired behaviour? (i.e. 2 extra queries)
|Comment by Benjamin Eberlei [ 26/Jul/11 ]|
First, you are using internal API therefore you are on your own anyways.
This is marked as improvment now, the functionality works, it may just be inefficient.
|Comment by Guilherme Blanco [ 09/Dec/11 ]|
I'm marking issue as invalid because you're conceptually wrong.
Correct code would be you to regenerate the collection (a new ArrayCollection) and just assign it to setTournamentLocations($newCollection);
Does this explanation is enough for you?
|Comment by Glen Ainscow [ 23/Dec/11 ]|
If I do this:
... then all the records are deleted, before adding the new records. This is inefficient and causes extra, unnecessary write operations.
Can't Doctrine perform diffs when persisting the collection, so that only the necessary deletes and inserts are executed?
|Comment by Guilherme Blanco [ 13/Jan/12 ]|
We could add it, but I don't think it worth the effort.
I'd rather consider that it's not possible to be done at the moment, but I need much more investigation for that. This will be something that I'll probably only do when I look at this issue again with a lot of time (which is really hard to happen).
If you have some spare time, feel free to make some attempts.