summaryrefslogtreecommitdiff
path: root/dbtests/updatetests.cpp
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2009-10-21 01:01:52 -0400
committerEliot Horowitz <eliot@10gen.com>2009-10-21 01:01:52 -0400
commitd54681458cad23fd6f4d1a2f5cfe8d8e15a9466e (patch)
tree761e672176e042c1a52de44d1286b105407673d5 /dbtests/updatetests.cpp
parentd188a16d18ef16f0bf4d48b40bdfd44bc6ae8fcd (diff)
downloadmongo-d54681458cad23fd6f4d1a2f5cfe8d8e15a9466e.tar.gz
$inc/$set work even if indexes - not 100% efficient now - SERVER-108
Diffstat (limited to 'dbtests/updatetests.cpp')
-rw-r--r--dbtests/updatetests.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/dbtests/updatetests.cpp b/dbtests/updatetests.cpp
index 9990f930291..24326f1b7ee 100644
--- a/dbtests/updatetests.cpp
+++ b/dbtests/updatetests.cpp
@@ -439,20 +439,23 @@ namespace UpdateTests {
client().ensureIndex( ns(), BSON( "a" << 1 ) );
client().insert( ns(), fromjson( "{'_id':0}" ) );
client().update( ns(), Query(), fromjson( "{$set:{'a.b':4}}" ) );
- ASSERT( client().findOne( ns(), Query() ).woCompare( fromjson( "{'_id':0}" ) ) == 0 );
+ ASSERT_EQUALS( fromjson( "{'_id':0,a:{b:4}}" ) , client().findOne( ns(), Query() ) );
+ ASSERT_EQUALS( fromjson( "{'_id':0,a:{b:4}}" ) , client().findOne( ns(), fromjson( "{'a.b':4}" ) ) ); // make sure the index works
}
};
- class ModParentOfIndex : public SetBase {
+ class IndexModSet : public SetBase {
public:
void run() {
client().ensureIndex( ns(), BSON( "a.b" << 1 ) );
- client().insert( ns(), fromjson( "{'_id':0}" ) );
- client().update( ns(), Query(), fromjson( "{$set:{'a':4}}" ) );
- ASSERT( client().findOne( ns(), Query() ).woCompare( fromjson( "{'_id':0}" ) ) == 0 );
+ client().insert( ns(), fromjson( "{'_id':0,a:{b:3}}" ) );
+ client().update( ns(), Query(), fromjson( "{$set:{'a.b':4}}" ) );
+ ASSERT_EQUALS( fromjson( "{'_id':0,a:{b:4}}" ) , client().findOne( ns(), Query() ) );
+ ASSERT_EQUALS( fromjson( "{'_id':0,a:{b:4}}" ) , client().findOne( ns(), fromjson( "{'a.b':4}" ) ) ); // make sure the index works
}
};
+
class PreserveIdWithIndex : public SetBase { // Not using $set, but base class is still useful
public:
void run() {
@@ -528,7 +531,7 @@ namespace UpdateTests {
add< DontDropEmpty >();
add< InsertInEmpty >();
add< IndexParentOfMod >();
- add< ModParentOfIndex >();
+ add< IndexModSet >();
add< PreserveIdWithIndex >();
add< CheckNoMods >();
add< UpdateMissingToNull >();