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:
parent
7935d23cca
commit
c9ed60974d
@ -333,7 +333,6 @@ namespace mongo {
|
||||
receivedDelete(m, currentOp);
|
||||
}
|
||||
else if ( op == dbKillCursors ) {
|
||||
mongolock lk(writeLock);
|
||||
currentOp.ensureStarted();
|
||||
logThreshold = 10;
|
||||
ss << "killcursors ";
|
||||
|
@ -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() ){
|
||||
|
@ -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
20
jstests/set6.js
Normal 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");
|
||||
|
Loading…
Reference in New Issue
Block a user