Skip to content

Commit

Permalink
NODE-563 fixes for handling the passing through of the variable
Browse files Browse the repository at this point in the history
  • Loading branch information
christkv committed Sep 18, 2015
1 parent 7c4638c commit a203270
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ node_js:
- 0.12
- "iojs"
- 4.0
sudo: false
sudo: true
env:
- MONGODB_VERSION=2.2.x
- MONGODB_VERSION=2.4.x
Expand Down
5 changes: 5 additions & 0 deletions lib/bulk/ordered.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,11 @@ var executeCommands = function(self, callback) {
finalOptions.serializeFunctions = true
}

// Serialize functions
if(self.s.options.ignoreUndefined) {
finalOptions.ignoreUndefined = true
}

// Is the bypassDocumentValidation options specific
if(self.s.bypassDocumentValidation == true) {
finalOptions.bypassDocumentValidation = true;
Expand Down
13 changes: 7 additions & 6 deletions lib/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,12 +473,6 @@ Collection.prototype.insertMany = function(docs, options, callback) {
insertMany: docs
}];

// Add ignoreUndfined
if(this.s.options.ignoreUndefined) {
options = shallowClone(options);
options.ignoreUndefined = this.s.options.ignoreUndefined;
}

// Execute using callback
if(typeof callback == 'function') return bulkWrite(self, operations, options, function(err, r) {
if(err) return callback(err, r);
Expand Down Expand Up @@ -566,6 +560,13 @@ Collection.prototype.bulkWrite = function(operations, options, callback) {
}

var bulkWrite = function(self, operations, options, callback) {
// Add ignoreUndfined
if(self.s.options.ignoreUndefined) {
options = shallowClone(options);
options.ignoreUndefined = self.s.options.ignoreUndefined;
}

// Create the bulk operation
var bulk = options.ordered == true || options.ordered == null ? self.initializeOrderedBulkOp(options) : self.initializeUnorderedBulkOp(options);

// for each op go through and add to the bulk
Expand Down
4 changes: 2 additions & 2 deletions test/functional/ignore_undefined_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exports['Should correctly insert document ignoring undefined field'] = {
metadata: { requires: { topology: ['single'] }},
// The actual test we wish to run
test: function(configuration, test) {
var db = configuration.newDbInstance(configuration.writeConcernMax(), {poolSize:1, ignoreUndefined:true});
var db = configuration.newDbInstance({ignoreUndefined:true}, {poolSize:1});
db.open(function(err, db) {
var collection = db.collection('shouldCorrectlyIgnoreUndefinedValue');
collection.insert({a:1, b:undefined}, configuration.writeConcernMax(), function(err, result) {
Expand Down Expand Up @@ -69,7 +69,7 @@ exports['Should correctly update document ignoring undefined field'] = {
test: function(configuration, test) {
var ObjectId = configuration.require.ObjectID;

var db = configuration.newDbInstance(configuration.writeConcernMax(), {poolSize:1, ignoreUndefined:true});
var db = configuration.newDbInstance({ignoreUndefined:true}, {poolSize:1});
db.open(function(err, db) {
var collection = db.collection('shouldCorrectlyIgnoreUndefinedValue2');
var id = new ObjectId();
Expand Down

0 comments on commit a203270

Please sign in to comment.