summaryrefslogtreecommitdiff
path: root/jstests/update5.js
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2009-07-22 21:37:23 -0400
committerEliot Horowitz <eliot@10gen.com>2009-07-22 21:37:23 -0400
commit0352532fa4243c01c2217d047da54c6c0ef38f54 (patch)
tree85219bf0bae623bf5a05cb660f622c14e0fbe1a6 /jstests/update5.js
parentbb334cfa6ffba20803f4e7bd6c17c7c98308dd29 (diff)
downloadmongo-0352532fa4243c01c2217d047da54c6c0ef38f54.tar.gz
test for $inc that fails
Diffstat (limited to 'jstests/update5.js')
-rw-r--r--jstests/update5.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/jstests/update5.js b/jstests/update5.js
new file mode 100644
index 00000000000..4ff9f1b9d38
--- /dev/null
+++ b/jstests/update5.js
@@ -0,0 +1,40 @@
+
+t = db.update5;
+
+function go( key ){
+
+ t.drop();
+
+ function check( num , name ){
+ assert.eq( 1 , t.find().count() , tojson( key ) + " count " + name );
+ assert.eq( num , t.findOne().n , tojson( key ) + " value " + name );
+ }
+
+ t.update( key , { $inc : { n : 1 } } , true );
+ check( 1 , "A" );
+
+ t.update( key , { $inc : { n : 1 } } , true );
+ check( 2 , "B" );
+
+ t.update( key , { $inc : { n : 1 } } , true );
+ check( 3 , "C" );
+
+ var ik = {};
+ for ( k in key )
+ ik[k] = 1;
+ t.ensureIndex( ik );
+
+ t.update( key , { $inc : { n : 1 } } , true );
+ check( 4 , "D" );
+
+}
+
+go( { a : 5 } );
+go( { a : 5 } );
+
+go( { a : 5 , b : 7 } );
+go( { a : null , b : 7 } );
+
+go( { referer: 'blah' } );
+//go( { referer: 'blah', name: 'bar' } );
+//go( { date: null, referer: 'blah', name: 'bar' } );