diff options
author | Eliot Horowitz <eliot@10gen.com> | 2010-08-04 15:15:10 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2010-08-04 15:15:30 -0400 |
commit | ae1e0804da17f2fbc3a38f89c090de2ed6101888 (patch) | |
tree | 9de306ea64882a0a3ad932bca409ece62cb67ee8 | |
parent | 50b7bbe9341084d24534a954277b1429d544610e (diff) | |
download | mongo-ae1e0804da17f2fbc3a38f89c090de2ed6101888.tar.gz |
fix upsert with $atomic SERVER-1568
-rw-r--r-- | db/update.cpp | 2 | ||||
-rw-r--r-- | jstests/repl/basic1.js | 8 |
2 files changed, 10 insertions, 0 deletions
diff --git a/db/update.cpp b/db/update.cpp index f80a9fa0df7..cbf93ba4d06 100644 --- a/db/update.cpp +++ b/db/update.cpp @@ -613,6 +613,8 @@ namespace mongo { BSONObjIteratorSorted i( query ); while ( i.more() ){ BSONElement e = i.next(); + if ( e.fieldName()[0] == '$' ) // for $atomic and anything else we add + continue; if ( e.type() == Object && e.embeddedObject().firstElement().fieldName()[0] == '$' ){ // this means this is a $gt type filter, so don't make part of the new object diff --git a/jstests/repl/basic1.js b/jstests/repl/basic1.js index 5a7dacec6af..701d71e4d65 100644 --- a/jstests/repl/basic1.js +++ b/jstests/repl/basic1.js @@ -141,6 +141,14 @@ assert.soon( function(){ return am.lotOfIndexes.getIndexes().length == as.lotOfI assert.eq( am.lotOfIndexes.getIndexes().length , as.lotOfIndexes.getIndexes().length , "lots of indexes b" ) +// multi-update with $inc + +am.mu1.update( { _id : 1 , $atomic : 1 } , { $inc : { x : 1 } } , true , true ) +x = { _id : 1 , x : 1 } +assert.eq( x , am.mu1.findOne() , "mu1" ); +assert.soon( function(){ z = as.mu1.findOne(); printjson( z ); return friendlyEqual( x , z ); } , "mu2" ) + + rt.stop(); |