Skip to content

Commit

Permalink
test: add test showing that bulkWrite strips out keys that arent in s…
Browse files Browse the repository at this point in the history
…chema by default re: code review on #15036
  • Loading branch information
vkarpov15 committed Nov 13, 2024
1 parent 98edf8b commit c9cbea0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions test/model.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4157,7 +4157,8 @@ describe('Model', function() {
filter: { _id: r1._id },
update: {
$set: {
'testArray.$[element].field1': field1update
'testArray.$[element].field1': field1update,
'testArray.$[element].nonexistentProp': field1update
}
},
arrayFilters: [
Expand All @@ -4168,8 +4169,9 @@ describe('Model', function() {
]
}
}]);
const r2 = await TestModel.findById(r1._id);
const r2 = await TestModel.findById(r1._id).lean();
assert.equal(r2.testArray[0].field1, field1update);
assert.strictEqual(r2.testArray[0].nonexistentProp, undefined);
});

it('with child timestamps and array filters (gh-7032)', async function() {
Expand Down

0 comments on commit c9cbea0

Please sign in to comment.