Skip to content

Commit c9cbea0

Browse files
committed
test: add test showing that bulkWrite strips out keys that arent in schema by default re: code review on #15036
1 parent 98edf8b commit c9cbea0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

test/model.test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4157,7 +4157,8 @@ describe('Model', function() {
41574157
filter: { _id: r1._id },
41584158
update: {
41594159
$set: {
4160-
'testArray.$[element].field1': field1update
4160+
'testArray.$[element].field1': field1update,
4161+
'testArray.$[element].nonexistentProp': field1update
41614162
}
41624163
},
41634164
arrayFilters: [
@@ -4168,8 +4169,9 @@ describe('Model', function() {
41684169
]
41694170
}
41704171
}]);
4171-
const r2 = await TestModel.findById(r1._id);
4172+
const r2 = await TestModel.findById(r1._id).lean();
41724173
assert.equal(r2.testArray[0].field1, field1update);
4174+
assert.strictEqual(r2.testArray[0].nonexistentProp, undefined);
41734175
});
41744176

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

0 commit comments

Comments
 (0)