Skip to content

Commit e806be4

Browse files
amotztembroadst
authored andcommitted
fix(bulk): honor ignoreUndefined in initializeUnorderedBulkOp
* initializeUnorderedBulkOp to honor ignoreUndefined All write operations (insertOne,update,updateMany etc...). honor the ignoreUndefined flag defined in the collection scope. Apparently UnorderedBulkOp was left out. This fixes it, makes UnorderedBulkOp honor the flag. * Fix lint * Add ignoreUndefined option to initializeOrderedBulkOp * Fix comment lower case * Give function's options precedence over session's options.
1 parent 050267d commit e806be4

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/collection.js

+11
Original file line numberDiff line numberDiff line change
@@ -2048,11 +2048,17 @@ Collection.prototype.mapReduce = function(map, reduce, options, callback) {
20482048
* @param {(number|string)} [options.w] The write concern.
20492049
* @param {number} [options.wtimeout] The write concern timeout.
20502050
* @param {boolean} [options.j=false] Specify a journal write concern.
2051+
* @param {boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields.
20512052
* @param {ClientSession} [options.session] optional session to use for this operation
20522053
* @return {UnorderedBulkOperation}
20532054
*/
20542055
Collection.prototype.initializeUnorderedBulkOp = function(options) {
20552056
options = options || {};
2057+
// Give function's options precedence over session options.
2058+
if (options.ignoreUndefined == null) {
2059+
options.ignoreUndefined = this.s.options.ignoreUndefined;
2060+
}
2061+
20562062
options.promiseLibrary = this.s.promiseLibrary;
20572063
return unordered(this.s.topology, this, options);
20582064
};
@@ -2066,11 +2072,16 @@ Collection.prototype.initializeUnorderedBulkOp = function(options) {
20662072
* @param {number} [options.wtimeout] The write concern timeout.
20672073
* @param {boolean} [options.j=false] Specify a journal write concern.
20682074
* @param {ClientSession} [options.session] optional session to use for this operation
2075+
* @param {boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields.
20692076
* @param {OrderedBulkOperation} callback The command result callback
20702077
* @return {null}
20712078
*/
20722079
Collection.prototype.initializeOrderedBulkOp = function(options) {
20732080
options = options || {};
2081+
// Give function's options precedence over session's options.
2082+
if (options.ignoreUndefined == null) {
2083+
options.ignoreUndefined = this.s.options.ignoreUndefined;
2084+
}
20742085
options.promiseLibrary = this.s.promiseLibrary;
20752086
return ordered(this.s.topology, this, options);
20762087
};

0 commit comments

Comments
 (0)