summaryrefslogtreecommitdiff
path: root/dbtests
diff options
context:
space:
mode:
authorAaron <aaron@10gen.com>2009-02-05 10:10:53 -0500
committerAaron <aaron@10gen.com>2009-02-05 10:10:53 -0500
commit9b7f4d830d90459b918e78e9ca9e58c33b4919f0 (patch)
tree9865bfc98c19fe3badf092eef2e5ccaa4e9a2c32 /dbtests
parent04c18a8576079fe93be1374af315f701b17cc175 (diff)
downloadmongo-9b7f4d830d90459b918e78e9ca9e58c33b4919f0.tar.gz
Don't update pattern if no key in matching object
Diffstat (limited to 'dbtests')
-rw-r--r--dbtests/repltests.cpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/dbtests/repltests.cpp b/dbtests/repltests.cpp
index 5b8a6cf103e..e3c69fcb9ac 100644
--- a/dbtests/repltests.cpp
+++ b/dbtests/repltests.cpp
@@ -132,10 +132,10 @@ namespace ReplTests {
theDataFileMgr.deleteRecord( ns, i->rec(), *i, true );
}
}
- static void insert( const BSONObj &o ) {
+ static void insert( const BSONObj &o, bool god = false ) {
dblock lk;
setClient( ns() );
- theDataFileMgr.insert( ns(), o.objdata(), o.objsize() );
+ theDataFileMgr.insert( ns(), o.objdata(), o.objsize(), god );
}
static BSONObj wid( const char *json ) {
class BSONObjBuilder b;
@@ -467,6 +467,29 @@ namespace ReplTests {
BSONObj o_, q_, u_, ou_;
};
+ class UpdateWithoutPreexistingId : public Base {
+ public:
+ UpdateWithoutPreexistingId() :
+ o_( fromjson( "{a:5}" ) ),
+ u_( fromjson( "{a:5}" ) ),
+ ot_( fromjson( "{b:4}" ) ) {}
+ void doIt() const {
+ client()->update( ns(), o_, u_ );
+ }
+ void check() const {
+ ASSERT_EQUALS( 2, count() );
+ checkOne( u_ );
+ checkOne( ot_ );
+ }
+ void reset() const {
+ deleteAll( ns() );
+ insert( ot_, true );
+ insert( o_, true );
+ }
+ protected:
+ BSONObj o_, u_, ot_;
+ };
+
class Remove : public Base {
public:
Remove() :
@@ -539,6 +562,7 @@ namespace ReplTests {
add< Idempotence::UpsertInsertIdMod >();
add< Idempotence::UpsertInsertSet >();
add< Idempotence::UpsertInsertInc >();
+ add< Idempotence::UpdateWithoutPreexistingId >();
add< Idempotence::Remove >();
add< Idempotence::RemoveOne >();
add< Idempotence::FailingUpdate >();