New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NODE 1155 - ignoreUndefined is not working in unordered bulkWrite #1550
Conversation
} | ||
}); | ||
|
||
it('should ignore undefined values in ordered bulk operation if `ignoreUndefined` specified', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for adding the test for the ordered bulk op too!
.initializeOrderedBulkOp({ ignoreUndefined: true }) | ||
.insert({ a: 1, b: undefined }) | ||
.execute() | ||
.then(() => col.find({}).toArray()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: we can use findOne
instead of find({}).toArray()
to return a single document - I don't think we need to change this, but just consider it in the future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah 👍
lib/bulk/ordered.js
Outdated
@@ -502,7 +502,7 @@ var executeCommands = function(self, callback) { | |||
finalOptions.serializeFunctions = true; | |||
} | |||
|
|||
// Serialize functions | |||
// Ingore undefined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignore
not Ingore
, see: Muphry's law
@jlord looks like the tests are failing because those two tests use the same collection name, and never drop the collection between runs resulting in a duplicate key error on the second insert attempt. |
This adds the check into unordered bulk operations to see if the
ignoreUndefined
option has been set totrue
.Tests added for both ordered and unordered bulk operations.
Fixes NODE-1155 ✨