-
Type: Bug
-
Resolution: Unresolved
-
Priority: Unknown
-
None
-
Affects Version/s: 7.3.3
-
Component/s: Persistence
-
None
Hello
We are having an issue with the following:
Data model: House embeds_many Rooms which embeds_many Residents
Actions -
- using assign_attributes to modify the last resident name
- deleting any resident other than the last resident
- saving
Expected outcome:
- The residents array size should be reduced by 1
- the last resident name to be modified correctly
Actual outcome:
The residents array size stays the same
- The before last resident element should be the last element, and its name is not modified as expected
- The last resident element is new "zombie" without an _id
- The last resident element zombie has the name that is supposed to be in the before last element
Attached a gist to reproduce the issue. following is an example of the House record after the run:
/* 1 */ { "_id" : ObjectId("628e8ade8d8b192100b504d1"), "rooms" : [ { "_id" : ObjectId("628e8ade8d8b192100b504cc"), "residents" : [ { "_id" : ObjectId("628e8ade8d8b192100b504d2"), "name" : "dude no 0" } ] }, { "_id" : ObjectId("628e8ade8d8b192100b504cd"), "residents" : [ { "_id" : ObjectId("628e8ade8d8b192100b504d3"), "name" : "dude no 1" } ] }, { "_id" : ObjectId("628e8ade8d8b192100b504cf"), "residents" : [ { "_id" : ObjectId("628e8ade8d8b192100b504d5"), "name" : "dude no 3" } ] }, { "_id" : ObjectId("628e8ade8d8b192100b504d0"), "residents" : [ { "_id" : ObjectId("628e8ade8d8b192100b504d6"), "name" : "dude no 4" } ] }, { "residents" : [ { "_id" : ObjectId("628e8ade8d8b192100b504d7"), "name" : "the new dude" } ] } ] }
Not sure if the cause if improper use of `assign_attributes` (or something else wrong with the gist...).
Please advise
Thank you
Boaz
p.s.
Love the T-Shirt Size input
- is related to
-
MONGOID-5294 Expand documentation of which association operations immediately save documents
- Backlog
-
MONGOID-5296 Do not immediately save referenced associations upon assignment
- Backlog
- links to