Skip to content

Commit

Permalink
Fixed checkKey problem with X.X keys on updates
Browse files Browse the repository at this point in the history
  • Loading branch information
christkv committed Aug 1, 2013
1 parent f1c3e49 commit 83162ba
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/mongodb/commands/update_command.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var UpdateCommand = exports.UpdateCommand = function(db, collectionName, spec, d
this.document = document;
this.db = db;
this.serializeFunctions = false;
this.checkKeys = typeof options.checkKeys != 'boolean' ? true : options.checkKeys;
this.checkKeys = typeof options.checkKeys != 'boolean' ? false : options.checkKeys;

// Generate correct flags
var db_upsert = 0;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ "name" : "mongodb"
, "description" : "A node.js driver for MongoDB"
, "keywords" : ["mongodb", "mongo", "driver", "db"]
, "version" : "1.3.13"
, "version" : "1.3.14"
, "author" : "Christian Amor Kvalheim <christkv@gmail.com>"
, "contributors" : [ "Aaron Heckmann",
"Christoph Pojer",
Expand Down
19 changes: 17 additions & 2 deletions test/tests/functional/insert_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -1695,7 +1695,7 @@ exports.shouldCorrectlyOverrideCheckKeysNativeOnUpdate = function(configuration,
db.open(function(err, db) {
db.collection('shouldCorrectlyOverrideCheckKeysNativeOnUpdate').update({
ps: {op: {'$set': 1}}
}, {'$set': {b: 1}}, function(err, doc) {
}, {'$set': {b: 1}}, {checkKeys:true}, function(err, doc) {
test.ok(err != null);

db.collection('shouldCorrectlyOverrideCheckKeysNativeOnUpdate').update({
Expand All @@ -1716,7 +1716,7 @@ exports.shouldCorrectlyOverrideCheckKeysJSOnUpdate = function(configuration, tes
db.open(function(err, db) {
db.collection('shouldCorrectlyOverrideCheckKeysJSOnUpdate').update({
ps: {op: {'$set': 1}}
}, {'$set': {b: 1}}, function(err, doc) {
}, {'$set': {b: 1}}, {checkKeys:true}, function(err, doc) {
test.ok(err != null);

db.collection('shouldCorrectlyOverrideCheckKeysJSOnUpdate').update({
Expand All @@ -1729,3 +1729,18 @@ exports.shouldCorrectlyOverrideCheckKeysJSOnUpdate = function(configuration, tes
});
});
}

exports.shouldCorrectlyWorkWithCheckKeys = function(configuration, test) {
var Long = configuration.getMongoPackage().Long;

var db = configuration.newDbInstance({w:1}, {native_parser:false})
db.open(function(err, db) {
db.collection('shouldCorrectlyOverrideCheckKeysJSOnUpdate').update({
"ps.op.t":1
}, {'$set': {b: 1}}, function(err, doc) {
test.equal(null, err);
db.close();
test.done();
});
});
}

0 comments on commit 83162ba

Please sign in to comment.