diff options
author | Eliot Horowitz <eliot@10gen.com> | 2013-01-28 10:55:04 -0500 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2013-01-28 10:55:23 -0500 |
commit | 07861f5341d4a8e95cc23037b6f245ca8b9110b5 (patch) | |
tree | fbaf9abe95533fee77df1fd52f64346552f5142d /src/mongo/dbtests/updatetests.cpp | |
parent | b7763e7355337502e6ed2ddd9e536646b0323aa3 (diff) | |
download | mongo-07861f5341d4a8e95cc23037b6f245ca8b9110b5.tar.gz |
SERVER-1606: don't duplicate update names
Diffstat (limited to 'src/mongo/dbtests/updatetests.cpp')
-rw-r--r-- | src/mongo/dbtests/updatetests.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/mongo/dbtests/updatetests.cpp b/src/mongo/dbtests/updatetests.cpp index 7f2b597e55a..96b7af74cfe 100644 --- a/src/mongo/dbtests/updatetests.cpp +++ b/src/mongo/dbtests/updatetests.cpp @@ -1726,7 +1726,7 @@ namespace UpdateTests { auto_ptr<ModSetState> modSetState = modSet.prepare( obj ); ASSERT_FALSE( modSetState->canApplyInPlace() ); modSetState->createNewFromMods(); - ASSERT_EQUALS( BSON( "$set" << BSON( "a" << 3 ) << "$set" << BSON("b" << 2)), + ASSERT_EQUALS( BSON( "$set" << BSON( "a" << 3 << "b" << 2)), modSetState->getOpLogRewrite() ); } }; @@ -1740,7 +1740,7 @@ namespace UpdateTests { auto_ptr<ModSetState> modSetState = modSet.prepare( obj ); ASSERT_FALSE( modSetState->canApplyInPlace() ); modSetState->createNewFromMods(); - ASSERT_EQUALS( BSON( "$set" << BSON( "a" << 1 ) << "$set" << BSON("b" << 2)), + ASSERT_EQUALS( BSON( "$set" << BSON( "a" << 1 << "b" << 2)), modSetState->getOpLogRewrite() ); } }; @@ -2025,7 +2025,7 @@ namespace UpdateTests { auto_ptr<ModSetState> modSetState = modSet.prepare( obj ); ASSERT_FALSE( modSetState->canApplyInPlace() ); modSetState->createNewFromMods(); - ASSERT_EQUALS( fromjson( "{ $set:{ 'a.b':[ 1 ] }, $set:{ 'a.c':[ 1 ] } }" ), + ASSERT_EQUALS( fromjson( "{ $set:{ 'a.b':[ 1 ] , 'a.c':[ 1 ] } }" ), modSetState->getOpLogRewrite() ); } }; @@ -2180,7 +2180,7 @@ namespace UpdateTests { auto_ptr<ModSetState> modSetState = modSet.prepare( obj ); ASSERT_FALSE( modSetState->canApplyInPlace() ); modSetState->createNewFromMods(); - ASSERT_EQUALS( BSON( "$unset" << BSON( "a" << 1 ) << "$set" << BSON ( "b" << 100 ) ), + ASSERT_EQUALS( BSON( "$set" << BSON( "b" << 100 ) << "$unset" << BSON ( "a" << 1 ) ), modSetState->getOpLogRewrite() ); } }; @@ -2194,7 +2194,7 @@ namespace UpdateTests { auto_ptr<ModSetState> modSetState = modSet.prepare( obj ); ASSERT_FALSE( modSetState->canApplyInPlace() ); modSetState->createNewFromMods(); - ASSERT_EQUALS( BSON( "$unset" << BSON( "a" << 1 ) << "$set" << BSON ( "b" << 100 ) ), + ASSERT_EQUALS( BSON( "$set" << BSON( "b" << 100 ) << "$unset" << BSON ( "a" << 1 ) ), modSetState->getOpLogRewrite() ); } }; @@ -2256,6 +2256,18 @@ namespace UpdateTests { } }; + class MultiSets { + public: + void run() { + BSONObj obj = BSON( "_id" << 1 << "a" << 1 << "b" << 1 ); + BSONObj mod = BSON( "$set" << BSON( "a" << 2 << "b" << 2 ) ); + ModSet modSet( mod ); + auto_ptr<ModSetState> modSetState = modSet.prepare( obj ); + ASSERT_TRUE( modSetState->canApplyInPlace() ); + ASSERT_EQUALS( mod, modSetState->getOpLogRewrite() ); + } + }; + class PositionalWithoutElemMatchKey { public: void run() { @@ -2724,6 +2736,7 @@ namespace UpdateTests { // add< ModSetTests::BitRewriteNonExistingField >(); add< ModSetTests::SetIsNotRewritten >(); add< ModSetTests::UnsetIsNotRewritten >(); + add< ModSetTests::MultiSets >(); add< ModSetTests::PositionalWithoutElemMatchKey >(); add< ModSetTests::PositionalWithoutNestedElemMatchKey >(); add< ModSetTests::DbrefPassesPositionalValidation >(); |