0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

fix upsert for DBRef SERVER-627

This commit is contained in:
Eliot Horowitz 2010-02-11 11:36:08 -05:00
parent 7935d23cca
commit c9ed60974d
4 changed files with 27 additions and 2 deletions

View File

@ -333,7 +333,6 @@ namespace mongo {
receivedDelete(m, currentOp);
}
else if ( op == dbKillCursors ) {
mongolock lk(writeLock);
currentOp.ensureStarted();
logThreshold = 10;
ss << "killcursors ";

View File

@ -1140,7 +1140,10 @@ namespace mongo {
if ( strchr( name , '.' ) ||
strchr( name , '$' ) ){
return false;
return
strcmp( name , "$ref" ) == 0 ||
strcmp( name , "$id" ) == 0
;
}
if ( e.mayEncapsulate() ){

View File

@ -633,6 +633,9 @@ namespace mongo {
int profile = cc().database()->profile;
StringBuilder& ss = debug.str;
if ( logLevel > 2 )
ss << " update: " << updateobj;
/* idea with these here it to make them loop invariant for multi updates, and thus be a bit faster for that case */
/* NOTE: when yield() is added herein, these must be refreshed after each call to yield! */
NamespaceDetails *d = nsdetails(ns); // can be null if an upsert...

20
jstests/set6.js Normal file
View File

@ -0,0 +1,20 @@
t = db.set6;
t.drop();
x = { _id : 1 , r : new DBRef( "foo" , new ObjectId() ) }
t.insert( x )
assert.eq( x , t.findOne() , "A" );
x.r.$id = new ObjectId()
t.update({}, { $set : { r : x.r } } );
assert.eq( x , t.findOne() , "B");
x.r2 = new DBRef( "foo2" , 5 )
t.update( {} , { $set : { "r2" : x.r2 } } );
assert.eq( x , t.findOne() , "C" )
x.r.$id = 2;
t.update( {} , { $set : { "r.$id" : 2 } } )
assert.eq( x.r.$id , t.findOne().r.$id , "D");