-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
1df72de apparently fixed MONGOID-964 but after going through and narrowing down this behavior commit by commit, I have found that the following is caused by 1df72de:
# Product embeds many Variations. # this is a totally empty rails 3 ruby 1.9.2 project specifically for testing mongoid # setup a product > p = Product.create => #<Product _id: 4e2c05a32abea95226000001, _type: nil, tag_ids: []> > p.variations.create => #<Variation _id: 4e2c05a52abea95226000002, _type: nil, name: nil> # get the product > p = Product.last => #<Product _id: 4e2c05a32abea95226000001, _type: nil, tag_ids: []> > a = p.attributes => {"_id"=>BSON::ObjectId('4e2c05a32abea95226000001'), "tag_ids"=>[], "variations"=>[{"_id"=>BSON::ObjectId('4e2c05a52abea95226000002')}]} > p = Product.last => #<Product _id: 4e2c05a32abea95226000001, _type: nil, tag_ids: []> # update it with its own attributes > p.update_attributes(a) => true # the embedded document has been duplicated and even has the same ID. > Product.last.variations => [#<Variation _id: 4e2c05a52abea95226000002, _type: nil, name: nil>, #<Variation _id: 4e2c05a52abea95226000002, _type: nil, name: nil>]
This only happens after 1df72de.