Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

SERVER-1470 fix upsert with dbref

  • Loading branch information...
commit f5fa68b120c00b0ccd9dbc95fe18502eb490feba 1 parent 9ce4fc4
@erh erh authored
Showing with 29 additions and 2 deletions.
  1. +20 −0 jstests/server1470.js
  2. +9 −2 src/mongo/db/ops/update_internal.cpp
View
20 jstests/server1470.js
@@ -0,0 +1,20 @@
+
+t = db.server1470;
+t.drop();
+
+q = { "name" : "first" , "pic" : { "$ref" : "foo", "$id" : ObjectId("4c48d04cd33a5a92628c9af6") } };
+t.update( q , {$set:{ x : 1 } } , true, true );
+ref = t.findOne().pic
+assert.eq( "object", typeof( ref ) );
+assert.eq( q.pic["$ref"] , ref["$ref"] )
+assert.eq( q.pic["$id"] , ref["$id"] )
+
+// just make we haven't broken other update operators
+t.drop();
+t.update( { _id : 1 , x : { $gt : 5 } } , { $set : { y : 1 } } , true );
+assert.eq( { _id : 1 , y : 1 } , t.findOne() );
+
+
+
+
+
View
11 src/mongo/db/ops/update_internal.cpp
@@ -790,8 +790,15 @@ namespace mongo {
continue;
if ( e.type() == Object && e.embeddedObject().firstElementFieldName()[0] == '$' ) {
- // this means this is a $gt type filter, so don't make part of the new object
- continue;
+ // we have something like { x : { $gt : 5 } }
+ // this can be a query piece
+ // or can be a dbref or something
+
+ int op = e.embeddedObject().firstElement().getGtLtOp( -1 );
+ if ( op >= 0 ) {
+ // this means this is a $gt type filter, so don't make part of the new object
+ continue;
+ }
}
eb.appendAs( e , e.fieldName() );
Please sign in to comment.
Something went wrong with that request. Please try again.