-
Type: Bug
-
Resolution: Cannot Reproduce
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
I have a document with a couple of embedded relationships. When updating AND inserting the same kind of embeds_many with the updated one receiving a field update and additional embedded docs (images), mongoid is not properly computing the separate updates to make. The model looks something like this:
model Content
embeds many Content Blocks
embeds many Content Assets
In the first example below, I've added Content Assets to an existing Content Block and added a few new Content Blocks, that works fine. In the second example below that fails, I've updated a field in an existing Content Block, added Content Assets to it AND added additional Content Blocks. For some reason Mongoid doesn't split these out properly, and when safe mode is turned on we get this error – failed with error 10151: "have conflicting mods in update”
THIS WORKS:
17:00:00 web.1 | MOPED: 127.0.0.1:27017 UPDATE database=theline_development collection=clear_cms_contents selector=
17:00:00 web.1 | MOPED: 127.0.0.1:27017 UPDATE database=theline_development collection=clear_cms_contents selector={"_id"=>"52585d3684cf810f72000cd7"}
update={"$pushAll"=>{"content_blocks"=>[
{"_id"=>"53767c50628c2d15c8000077", "type"=>"", "body"=>"", "order"=>nil, "has_gallery"=>false}]}} flags=[] (0.2232m
THIS ONE DOESN’T:
16:56:48 web.1 | MOPED: 127.0.0.1:27017 UPDATE database=theline_development collection=clear_cms_contents selector=
16:56:48 web.1 | MOPED: 127.0.0.1:27017 UPDATE database=theline_development collection=clear_cms_contents selector={"_id"=>"52585d3684cf810f72000cd7"}
update={"$pushAll"=>{"content_blocks.0.content_assets"=>[
{"_id"=>"53767b90628c2d8159000071", "path"=>"theline/2014/05/16", "file"=>"cropped_DSC_0020.JPG", "title"=>"cropped_DSC_0020.JPG", "description"=>"", "credit"=>"", "tags"=>[], "order"=>50, "width"=>"1736", "height"=>"1736"}], "content_blocks"=>[
{"_id"=>"53767b90628c2d8159000072", "type"=>"", "body"=>"", "order"=>nil, "has_gallery"=>false}]}} flags=[] (0.5341ms)
Code versions:
moped (1.5.2)
origin (1.1.0)
mongoid (3.1.6)