Skip to content

Commit

Permalink
Merge pull request mongodb#320 from year2013/master
Browse files Browse the repository at this point in the history
Timeout option in collection.find() not passed correctly to Cursor if false
  • Loading branch information
christkv committed Aug 19, 2011
2 parents af5fdf8 + b74743b commit cffa65e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/mongodb/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ Collection.prototype.find = function find () {
options.skip = len > 3 ? args[2] : options.skip ? options.skip : 0;
options.limit = len > 3 ? args[3] : options.limit ? options.limit : 0;
options.hint = options.hint != null ? this.normalizeHintField(options.hint) : this.internalHint;
options.timeout = len == 5 ? args[4] : options.timeout ? options.timeout : undefined;
options.timeout = len == 5 ? args[4] : typeof options.timeout === 'undefined' ? undefined : options.timeout;
// If we have overridden slaveOk otherwise use the default db setting
options.slaveOk = options.slaveOk != null ? options.slaveOk : this.db.slaveOk;

Expand Down
20 changes: 18 additions & 2 deletions test/find_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -770,10 +770,26 @@ var tests = testCase({
})
});
});
}
},

'Should correctly pass timeout options to cursor' : function(test) {
client.createCollection('timeoutFalse', function(err, collection) {
collection.find({},{timeout:false},function(err, cursor) {
test.equal(false, cursor.timeout);
});
collection.find({},{timeout:true},function(err, cursor) {
test.equal(true, cursor.timeout);
});
collection.find({},{},function(err, cursor) {
test.equal(true, cursor.timeout);
});

test.done();
});
}
})

// Stupid freaking workaround due to there being no way to run setup once for each suite
var numberOfTestsRun = Object.keys(tests).length;
// Assign out tests
module.exports = tests;
module.exports = tests;

0 comments on commit cffa65e

Please sign in to comment.