summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2010-02-11 11:36:08 -0500
committerEliot Horowitz <eliot@10gen.com>2010-02-11 11:36:08 -0500
commitc9ed60974d3a795a25353f3790d6af6093bfad3d (patch)
tree58645be3da883ec089c3289318b73a269ea25dbd
parent7935d23cca442aa696fd266b2339bc46d9d838bf (diff)
downloadmongo-c9ed60974d3a795a25353f3790d6af6093bfad3d.tar.gz
fix upsert for DBRef SERVER-627
-rw-r--r--db/instance.cpp1
-rw-r--r--db/jsobj.cpp5
-rw-r--r--db/update.cpp3
-rw-r--r--jstests/set6.js20
4 files changed, 27 insertions, 2 deletions
diff --git a/db/instance.cpp b/db/instance.cpp
index e4ff204c0a0..e085532dc78 100644
--- a/db/instance.cpp
+++ b/db/instance.cpp
@@ -333,7 +333,6 @@ namespace mongo {
receivedDelete(m, currentOp);
}
else if ( op == dbKillCursors ) {
- mongolock lk(writeLock);
currentOp.ensureStarted();
logThreshold = 10;
ss << "killcursors ";
diff --git a/db/jsobj.cpp b/db/jsobj.cpp
index 27403516337..2b3359ceb6b 100644
--- a/db/jsobj.cpp
+++ b/db/jsobj.cpp
@@ -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() ){
diff --git a/db/update.cpp b/db/update.cpp
index c75731317c1..d5f05d64e27 100644
--- a/db/update.cpp
+++ b/db/update.cpp
@@ -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...
diff --git a/jstests/set6.js b/jstests/set6.js
new file mode 100644
index 00000000000..d41e7aba971
--- /dev/null
+++ b/jstests/set6.js
@@ -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");
+