Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix un-sorted update

  • Loading branch information...
commit e9257ac7518b61bef5cdcde4215d9043b5a369b5 1 parent a71ff07
@erh erh authored
Showing with 20 additions and 1 deletion.
  1. +1 −1  db/update.cpp
  2. +19 −0 jstests/update9.js
View
2  db/update.cpp
@@ -317,7 +317,7 @@ namespace mongo {
}
void ModSet::createNewFromMods( const string& root , BSONObjBuilder& b , const BSONObj &obj ){
- BSONObjIterator es( obj );
+ BSONObjIteratorSorted es( obj );
BSONElement e = es.next();
ModHolder::iterator m = _mods.lower_bound( root );
View
19 jstests/update9.js
@@ -0,0 +1,19 @@
+
+t = db.update9;
+t.drop()
+
+orig = { "_id" : 1 ,
+ "question" : "a",
+ "choices" : { "1" : { "choice" : "b" },
+ "0" : { "choice" : "c" } } ,
+
+ }
+
+t.save( orig );
+assert.eq( orig , t.findOne() , "A" );
+
+t.update({_id: 1, 'choices.0.votes': {$ne: 1}}, {$push: {'choices.0.votes': 1}})
+
+orig.choices["0"].votes = [ 1 ] ;
+assert.eq( orig.choices["0"] , t.findOne().choices["0"] , "B" );
+
Please sign in to comment.
Something went wrong with that request. Please try again.