summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
Diffstat (limited to 'jstests')
-rw-r--r--jstests/set7.js11
-rw-r--r--jstests/update6.js2
-rw-r--r--jstests/updatee.js6
-rw-r--r--jstests/updatek.js13
4 files changed, 28 insertions, 4 deletions
diff --git a/jstests/set7.js b/jstests/set7.js
index c6d311bc6d4..7f7989f39d8 100644
--- a/jstests/set7.js
+++ b/jstests/set7.js
@@ -39,6 +39,17 @@ t.update( {}, {$set:{"a.f":1}} );
assert( db.getLastError() );
assert.eq( [], t.findOne().a );
+// Test requiring proper ordering of multiple mods.
+t.drop();
+t.save( {a:[0,1,2,3,4,5,6,7,8,9,10]} );
+t.update( {}, {$set:{"a.11":11,"a.2":-2}} );
+assert.eq( [0,1,-2,3,4,5,6,7,8,9,10,11], t.findOne().a );
+
+// Test upsert case
+t.drop();
+t.update( {a:[0,1,2,3,4,5,6,7,8,9,10]}, {$set:{"a.11":11} }, true );
+assert.eq( [0,1,2,3,4,5,6,7,8,9,10,11], t.findOne().a );
+
// SERVER-3750
t.drop();
t.save( {a:[]} );
diff --git a/jstests/update6.js b/jstests/update6.js
index f54767751f0..1f42fe5dead 100644
--- a/jstests/update6.js
+++ b/jstests/update6.js
@@ -10,7 +10,7 @@ assert.eq( "c,d" , Object.keySet( t.findOne().b ).toString() , "B" );
t.update( { a : 1 } , { $inc : { "b.0e" : 1 } } );
assert.eq( 1 , t.findOne().b["0e"] , "C" );
-assert.eq( "c,d,0e" , Object.keySet( t.findOne().b ).toString() , "D" );
+assert.eq( "0e,c,d" , Object.keySet( t.findOne().b ).toString() , "D" );
// -----
diff --git a/jstests/updatee.js b/jstests/updatee.js
index 228eba018d6..85ba37c5c05 100644
--- a/jstests/updatee.js
+++ b/jstests/updatee.js
@@ -29,7 +29,7 @@ t.update({"profile-id" : "test"}, {$set: {"actual.02": "v4"}});
q = t.findOne();
assert.eq(q.actual["02"], "v4", "A4");
-assert(!q.actual["002"], "A5");
+assert.eq(q.actual["002"], "val4", "A5");
t.update({"_id" : 1}, {$set : {"actual.2139043290148390248219423941.b" : 4}});
q = t.findOne();
@@ -51,12 +51,12 @@ assert.eq(q.actual["000"], "val000", "A8 zeros");
t.update({"_id" : 1}, {$set : {"actual.00" : "val00"}});
q = t.findOne();
assert.eq(q.actual["00"], "val00", "A8 00");
-assert(!q.actual["000"], "A9");
+assert.eq(q.actual["000"], "val000", "A9");
t.update({"_id" : 1}, {$set : {"actual.000" : "val000"}});
q = t.findOne();
assert.eq(q.actual["000"], "val000", "A9");
-assert(!q.actual["00"], "A10");
+assert.eq(q.actual["00"], "val00", "A10");
t.update({"_id" : 1}, {$set : {"actual.01" : "val01"}});
q = t.findOne();
diff --git a/jstests/updatek.js b/jstests/updatek.js
new file mode 100644
index 00000000000..b3a1d39c376
--- /dev/null
+++ b/jstests/updatek.js
@@ -0,0 +1,13 @@
+// Test modifier operations on numerically equivalent string field names. SERVER-4776
+
+t = db.jstests_updatek;
+
+t.drop();
+t.save( { _id:0, '1':{}, '01':{} } );
+t.update( {}, { $set:{ '1.b':1, '1.c':2 } } );
+assert.eq( { '01':{}, '1':{ b:1, c:2 }, _id:0 }, t.findOne() );
+
+t.drop();
+t.save( { _id:0, '1':{}, '01':{} } );
+t.update( {}, { $set:{ '1.b':1, '01.c':2 } } );
+assert.eq( { '01':{ c:2 }, '1':{ b:1 }, _id:0 }, t.findOne() );