diff options
author | Eliot Horowitz <eliot@10gen.com> | 2009-07-22 21:37:23 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2009-07-22 21:37:23 -0400 |
commit | 0352532fa4243c01c2217d047da54c6c0ef38f54 (patch) | |
tree | 85219bf0bae623bf5a05cb660f622c14e0fbe1a6 /jstests/update5.js | |
parent | bb334cfa6ffba20803f4e7bd6c17c7c98308dd29 (diff) | |
download | mongo-0352532fa4243c01c2217d047da54c6c0ef38f54.tar.gz |
test for $inc that fails
Diffstat (limited to 'jstests/update5.js')
-rw-r--r-- | jstests/update5.js | 40 |
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' } ); |