Using concat with an empty array on an array of subdocuments seems to incorrectly mark fields as changed #10272
Labels
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
Milestone
Do you want to request a feature or report a bug?
bug
What is the current behavior?
Using
concat
on an already changed array seems to override the fact that the array has changed. This seems to be a very obscure issue and I have only been able to reproduce it by callingconcat
with an empty array.If the current behavior is a bug, please provide the steps to reproduce.
Using the following model:
Doing the following operation:
The console.log should contain the names "John" and "Mary", but contains "John", "Jane", and "Mary". The reason is because mongoose performs only a
$push
query for "Mary"What is the expected behavior?
The
children
on the document should only contain the names "John" and "Mary"What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Mongoose: 5.12.10
MongoDB: 4.2
NodeJS: 12.16.1
The text was updated successfully, but these errors were encountered: