Skip to content

Commit

Permalink
Merge remote branch 'nw/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Amor Kvalheim committed Jun 17, 2010
2 parents a1a74ff + d8bf321 commit f2d9b8f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
13 changes: 13 additions & 0 deletions integration/integration_tests.js
Expand Up @@ -3334,6 +3334,18 @@ var all_tests = {
});
},

test_find_one_error_handling : function() {
client.createCollection('test_find_one_error_handling', function(err, collection) {
// Try to fetch an object using a totally invalid and wrong hex string... what we're interested in here
// is the error handling of the findOne Method
try {
collection.findOne({"_id":ObjectID.createFromHexString('5e9bd59248305adf18ebc15703a1')}, function(err, result) {});
} catch (err) {
finished_test({test_find_one_error_handling:'ok'});
}
});
},

// test_force_binary_error : function() {
// client.createCollection('test_force_binary_error', function(err, collection) {
// // Try to fetch an object using a totally invalid and wrong hex string... what we're interested in here
Expand Down Expand Up @@ -3621,6 +3633,7 @@ function run_tests() {
});
}


function finished_test(test_object) {
for(var name in test_object) {
sys.puts("= executing test: " + name + " [" + test_object[name] + "]");
Expand Down
4 changes: 3 additions & 1 deletion lib/mongodb/bson/bson.js
Expand Up @@ -483,7 +483,9 @@ var Code = exports.Code = function(code, scope) {
Object ID used to create object id's for the mongo requests
**/
var ObjectID = exports.ObjectID = function(id) {
id == null ? this.id = this.generate() : this.id = id;
if(id == null) this.id = this.generate();
else if( /^[0-9a-fA-F]{24}$/.test(id)) return ObjectID.createFromHexString(id);
else this.id = id;
};

ObjectID.prototype.get_inc = function() {
Expand Down

0 comments on commit f2d9b8f

Please sign in to comment.