Skip to content

Commit

Permalink
fix(bulk): honor ignoreUndefined in initializeUnorderedBulkOp
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
amotzte authored and mbroadst committed Jan 22, 2019
1 parent 050267d commit e806be4
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/collection.js
Expand Up @@ -2048,11 +2048,17 @@ Collection.prototype.mapReduce = function(map, reduce, options, callback) {
* @param {(number|string)} [options.w] The write concern.
* @param {number} [options.wtimeout] The write concern timeout.
* @param {boolean} [options.j=false] Specify a journal write concern.
* @param {boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields.
* @param {ClientSession} [options.session] optional session to use for this operation
* @return {UnorderedBulkOperation}
*/
Collection.prototype.initializeUnorderedBulkOp = function(options) {
options = options || {};
// Give function's options precedence over session options.
if (options.ignoreUndefined == null) {
options.ignoreUndefined = this.s.options.ignoreUndefined;
}

options.promiseLibrary = this.s.promiseLibrary;
return unordered(this.s.topology, this, options);
};
Expand All @@ -2066,11 +2072,16 @@ Collection.prototype.initializeUnorderedBulkOp = function(options) {
* @param {number} [options.wtimeout] The write concern timeout.
* @param {boolean} [options.j=false] Specify a journal write concern.
* @param {ClientSession} [options.session] optional session to use for this operation
* @param {boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields.
* @param {OrderedBulkOperation} callback The command result callback
* @return {null}
*/
Collection.prototype.initializeOrderedBulkOp = function(options) {
options = options || {};
// Give function's options precedence over session's options.
if (options.ignoreUndefined == null) {
options.ignoreUndefined = this.s.options.ignoreUndefined;
}
options.promiseLibrary = this.s.promiseLibrary;
return ordered(this.s.topology, this, options);
};
Expand Down

0 comments on commit e806be4

Please sign in to comment.