Thanks Guilherme. If I understand correctly, your PR (which is not included in 
v2.5.0?) only affects collections that are REPLACED with a new instance, but 
not those with elements deleted then added?

 

Regarding the specific use case of deleting then adding elements within the 
same collection, is there a bug open for this, or should I open one?

 

From: [email protected] [mailto:[email protected]] On 
Behalf Of [email protected]
Sent: 22 July 2015 00:26
To: doctrine-user
Subject: Re: [doctrine-user] DELETE and INSERT order in collection flush

 

I'd say this change is long required.

I've done is as part of one-to-many-orphan-removal issue I've fixed.

You can see the change to UoW here: 
https://github.com/doctrine/doctrine2/commit/1fa540732f248d51f80384290a66475dc7b9dbdc#diff-6e8c1c1e78b054ba05e20ea09d877865

 

[]s,

 

On Tue, Jul 21, 2015 at 6:14 PM, Benjamin Morel <[email protected]> 
wrote:

Hi, when I remove() an item from a Doctrine 2 collection, then add() another, I 
noticed that Doctrine performs the INSERT before the DELETE, which causes a 
unique key constraint to fail on MySQL because the two items cannot coexist at 
the same time (MySQL doesn't have deferred constraints at this time).

 

Is there a way to configure Doctrine so that the DELETE happens before the 
INSERT when the collection is synced with the database, without having to 
flush() manually between the delete() and add()?

Also, is there a particular reason for this default behaviour, or is this a bug 
in Doctrine 2 that should be reported?

 

Thanks in advance for any insight.
Ben

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.





 

-- 

Guilherme Blanco
MSN: [email protected]
GTalk: guilhermeblanco
Toronto - ON/Canada

-- 
You received this message because you are subscribed to a topic in the Google 
Groups "doctrine-user" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/doctrine-user/JjJ561BODcQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to 
[email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to