-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
None
When we need to change the order of one embedded Array, like the following code:
person = Person.create existing_address = person.addresses.create(street: "Oxford St") new_address = person.addresses.build(street: "Oxford St") person.addresses[0] = new_address person.addresses[1] = existing_address
So, when I call atomic_updates, Mongoid is not considering conflicts:
{ "$set" => { "title" => "Sir", "addresses.0.street" => "Bond St" }, "$pushAll" => { "addresses" => [{ "_id" => new_address.id, "street" => "Another", "locations" => [ "_id" => location.id, "name" => "Home" ] }] } }
The pull request consider $pullAll operation when Mongoid is generating $set operation.
Other option to resolve the problem is change the method _children to return new embedded objects on the final of Array.