Skip to content

Commit

Permalink
fix(document): correctly handle modifying array subdocument after set…
Browse files Browse the repository at this point in the history
…ting array subdocument to itself

Fix #11172
  • Loading branch information
vkarpov15 committed Jan 15, 2022
1 parent e4145f9 commit 1c6a89a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -1673,6 +1673,9 @@ Document.prototype.$__set = function(pathToMark, path, options, constructing, pa
} else if (Array.isArray(val) && val.isMongooseArray && Array.isArray(priorVal) && priorVal.isMongooseArray) {
val[arrayAtomicsSymbol] = priorVal[arrayAtomicsSymbol];
val[arrayAtomicsBackupSymbol] = priorVal[arrayAtomicsBackupSymbol];
if (val.isMongooseDocumentArray) {
val.forEach(doc => { doc.isNew = false; });
}
}

let obj = this._doc;
Expand Down

0 comments on commit 1c6a89a

Please sign in to comment.