-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
None
...s
When pushing or pulling values of embedded documents in different levels on a document in a single update mongoid complains with a "have conflicting mods in update" error. This change splits the conflicting operations into multiple ones, thus avoiding the error.
For example, before this change when you had two pulls like this:
{ "addresses.0.locations" => { "_id" => { "$in" => [ "two" ]}} } # $pull { "addresses" => { "_id" => { "$in" => [ "one" ]}} } # $pull
Mongoid would generate a single update, and MongoDB would complain with a "have conflicting mods in update" error.
Also if you had a set and two conflicting pushes like this:
{ "addresses.0.street" => "Bond" } # $set { "addresses.0.locations" => { "street" => "Bond St" } } # $pushAll { "addresses" => { "street" => "Oxford St" } } # $pushAll
It would also generate an update with the $set and other with two $pushAll, and this second update would fail.
The change makes any conflict like this to generate an update.