0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 00:56:44 +01:00

fix un-sorted update

This commit is contained in:
Eliot Horowitz 2009-12-18 01:51:43 -05:00
parent a71ff07701
commit e9257ac751
2 changed files with 20 additions and 1 deletions

View File

@ -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 );

19
jstests/update9.js Normal file
View File

@ -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" );