summaryrefslogtreecommitdiff
path: root/src/mongo/dbtests/updatetests.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/dbtests/updatetests.cpp')
-rw-r--r--src/mongo/dbtests/updatetests.cpp439
1 files changed, 248 insertions, 191 deletions
diff --git a/src/mongo/dbtests/updatetests.cpp b/src/mongo/dbtests/updatetests.cpp
index 63ee44d438f..474402e99f8 100644
--- a/src/mongo/dbtests/updatetests.cpp
+++ b/src/mongo/dbtests/updatetests.cpp
@@ -177,7 +177,8 @@ public:
ASSERT(!_client
.findOne(ns(),
BSON("a"
- << "c"))
+ << "c"),
+ Query())
.isEmpty());
}
};
@@ -196,7 +197,8 @@ public:
ASSERT(!_client
.findOne(ns(),
BSON("a"
- << "cd"))
+ << "cd"),
+ Query())
.isEmpty());
}
};
@@ -207,7 +209,7 @@ public:
_client.insert(ns(),
BSON("a"
<< "b"));
- _client.update(ns(), Query(), BSON("$set" << BSON("a" << 5)));
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$set" << BSON("a" << 5)));
ASSERT(!_client.findOne(ns(), BSON("a" << 5)).isEmpty());
}
};
@@ -218,7 +220,7 @@ public:
_client.insert(ns(),
BSON("a"
<< "bcd"));
- _client.update(ns(), Query(), BSON("$set" << BSON("a" << 5.0)));
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$set" << BSON("a" << 5.0)));
ASSERT(!_client.findOne(ns(), BSON("a" << 5.0)).isEmpty());
}
};
@@ -228,11 +230,11 @@ public:
void run() {
// Try with upsert false first.
_client.insert(ns(), BSONObj() /* empty document */);
- _client.update(ns(), Query(), BSON("$setOnInsert" << BSON("a" << 1)), false);
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$setOnInsert" << BSON("a" << 1)), false);
ASSERT(_client.findOne(ns(), BSON("a" << 1)).isEmpty());
// Then with upsert true.
- _client.update(ns(), Query(), BSON("$setOnInsert" << BSON("a" << 1)), true);
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$setOnInsert" << BSON("a" << 1)), true);
ASSERT(_client.findOne(ns(), BSON("a" << 1)).isEmpty());
}
};
@@ -241,11 +243,11 @@ class SetOnInsertFromNonExistent : public SetBase {
public:
void run() {
// Try with upsert false first.
- _client.update(ns(), Query(), BSON("$setOnInsert" << BSON("a" << 1)), false);
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$setOnInsert" << BSON("a" << 1)), false);
ASSERT(_client.findOne(ns(), BSON("a" << 1)).isEmpty());
// Then with upsert true.
- _client.update(ns(), Query(), BSON("$setOnInsert" << BSON("a" << 1)), true);
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$setOnInsert" << BSON("a" << 1)), true);
ASSERT(!_client.findOne(ns(), BSON("a" << 1)).isEmpty());
}
};
@@ -253,14 +255,12 @@ public:
class SetOnInsertFromNonExistentWithQuery : public SetBase {
public:
void run() {
- Query q("{a:1}");
-
// Try with upsert false first.
- _client.update(ns(), q, BSON("$setOnInsert" << BSON("b" << 1)), false);
+ _client.update(ns(), BSON("a" << 1), BSON("$setOnInsert" << BSON("b" << 1)), false);
ASSERT(_client.findOne(ns(), BSON("a" << 1)).isEmpty());
// Then with upsert true.
- _client.update(ns(), q, BSON("$setOnInsert" << BSON("b" << 1)), true);
+ _client.update(ns(), BSON("a" << 1), BSON("$setOnInsert" << BSON("b" << 1)), true);
ASSERT(!_client.findOne(ns(), BSON("a" << 1 << "b" << 1)).isEmpty());
}
};
@@ -268,14 +268,12 @@ public:
class SetOnInsertFromNonExistentWithQueryOverField : public SetBase {
public:
void run() {
- Query q("{a:1}"); // same field that we'll setOnInsert on
-
// Try with upsert false first.
- _client.update(ns(), q, BSON("$setOnInsert" << BSON("a" << 2)), false);
+ _client.update(ns(), BSON("a" << 1), BSON("$setOnInsert" << BSON("a" << 2)), false);
ASSERT(_client.findOne(ns(), BSON("a" << 1)).isEmpty());
// Then with upsert true.
- _client.update(ns(), q, BSON("$setOnInsert" << BSON("a" << 2)), true);
+ _client.update(ns(), BSON("a" << 1), BSON("$setOnInsert" << BSON("a" << 2)), true);
ASSERT(!_client.findOne(ns(), BSON("a" << 2)).isEmpty());
}
};
@@ -285,7 +283,7 @@ public:
void run() {
BSONObj res = fromjson("{'_id':0, a:1}");
_client.insert(ns(), res);
- _client.update(ns(), Query(), BSON("$setOnInsert" << BSON("b" << 1)));
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$setOnInsert" << BSON("b" << 1)));
ASSERT(_client.findOne(ns(), BSON("a" << 1)).woCompare(res) == 0);
}
};
@@ -294,7 +292,7 @@ class SetOnInsertExisting : public SetBase {
public:
void run() {
_client.insert(ns(), BSON("a" << 1));
- _client.update(ns(), Query(), BSON("$setOnInsert" << BSON("a" << 2)));
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$setOnInsert" << BSON("a" << 2)));
ASSERT(!_client.findOne(ns(), BSON("a" << 1)).isEmpty());
}
};
@@ -304,14 +302,14 @@ public:
void run() {
// Try with upsert false first.
_client.update(ns(),
- Query(),
+ BSONObj{} /*filter*/,
BSON("$set" << BSON("a" << 1) << "$setOnInsert" << BSON("b" << 2)),
false);
ASSERT(_client.findOne(ns(), BSON("a" << 1 << "b" << 2)).isEmpty());
// Then with upsert true.
_client.update(ns(),
- Query(),
+ BSONObj{} /*filter*/,
BSON("$set" << BSON("a" << 1) << "$setOnInsert" << BSON("b" << 2)),
true);
ASSERT(!_client.findOne(ns(), BSON("a" << 1 << "b" << 2)).isEmpty());
@@ -336,9 +334,9 @@ class ModDotted : public SetBase {
public:
void run() {
_client.insert(ns(), fromjson("{a:{b:4}}"));
- _client.update(ns(), Query(), BSON("$inc" << BSON("a.b" << 10)));
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$inc" << BSON("a.b" << 10)));
ASSERT(!_client.findOne(ns(), BSON("a.b" << 14)).isEmpty());
- _client.update(ns(), Query(), BSON("$set" << BSON("a.b" << 55)));
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$set" << BSON("a.b" << 55)));
ASSERT(!_client.findOne(ns(), BSON("a.b" << 55)).isEmpty());
}
};
@@ -348,13 +346,14 @@ public:
void run() {
_client.insert(ns(), fromjson("{a:{b:'cdef'}}"));
_client.update(ns(),
- Query(),
+ BSONObj{} /*filter*/,
BSON("$set" << BSON("a.b"
<< "llll")));
ASSERT(!_client
.findOne(ns(),
BSON("a.b"
- << "llll"))
+ << "llll"),
+ Query())
.isEmpty());
}
};
@@ -364,13 +363,14 @@ public:
void run() {
_client.insert(ns(), fromjson("{'_id':0,a:{b:'cdef'}}"));
_client.update(ns(),
- Query(),
+ BSONObj{} /*filter*/,
BSON("$set" << BSON("a.b"
<< "lllll")));
ASSERT(_client
.findOne(ns(),
BSON("a.b"
- << "lllll"))
+ << "lllll"),
+ Query())
.woCompare(fromjson("{'_id':0,a:{b:'lllll'}}")) == 0);
}
};
@@ -386,7 +386,8 @@ public:
ASSERT(_client
.findOne(ns(),
BSON("a.b"
- << "lllll"))
+ << "lllll"),
+ Query())
.woCompare(fromjson("{'_id':0,a:{b:'lllll'}}")) == 0);
}
};
@@ -396,12 +397,13 @@ public:
void run() {
_client.insert(ns(), fromjson("{'_id':0,a:{c:4}}"));
_client.update(ns(),
- Query(),
+ BSONObj{} /*filter*/,
BSON("$set" << BSON("a.b"
<< "lllll")));
ASSERT_EQUALS(mutablebson::unordered(_client.findOne(ns(),
BSON("a.b"
- << "lllll"))),
+ << "lllll"),
+ Query())),
mutablebson::unordered(fromjson("{'_id':0,a:{b:'lllll',c:4}}")));
}
};
@@ -410,8 +412,9 @@ class IncMissing : public SetBase {
public:
void run() {
_client.insert(ns(), fromjson("{'_id':0}"));
- _client.update(ns(), Query(), BSON("$inc" << BSON("f" << 3.0)));
- ASSERT(_client.findOne(ns(), Query()).woCompare(fromjson("{'_id':0,f:3}")) == 0);
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$inc" << BSON("f" << 3.0)));
+ ASSERT(_client.findOne(ns(), BSONObj{} /*filter*/).woCompare(fromjson("{'_id':0,f:3}")) ==
+ 0);
}
};
@@ -419,8 +422,8 @@ class MultiInc : public SetBase {
public:
string s() {
stringstream ss;
- unique_ptr<DBClientCursor> cc =
- _client.query(NamespaceString(ns()), Query().sort(BSON("_id" << 1)));
+ unique_ptr<DBClientCursor> cc = _client.query(
+ NamespaceString(ns()), BSONObj{} /*filter*/, Query().sort(BSON("_id" << 1)));
bool first = true;
while (cc->more()) {
if (first)
@@ -455,8 +458,9 @@ class UnorderedNewSet : public SetBase {
public:
void run() {
_client.insert(ns(), fromjson("{'_id':0}"));
- _client.update(ns(), Query(), BSON("$set" << BSON("f.g.h" << 3.0 << "f.g.a" << 2.0)));
- ASSERT_EQUALS(mutablebson::unordered(_client.findOne(ns(), Query())),
+ _client.update(
+ ns(), BSONObj{} /*filter*/, BSON("$set" << BSON("f.g.h" << 3.0 << "f.g.a" << 2.0)));
+ ASSERT_EQUALS(mutablebson::unordered(_client.findOne(ns(), BSONObj{} /*filter*/)),
mutablebson::unordered(fromjson("{'_id':0,f:{g:{a:2,h:3}}}")));
}
};
@@ -466,7 +470,7 @@ public:
void run() {
_client.insert(ns(), fromjson("{'_id':0}"));
_client.update(ns(), BSONObj(), BSON("$set" << BSON("f.g.h.b" << 3.0 << "f.g.a.b" << 2.0)));
- ASSERT_EQUALS(mutablebson::unordered(_client.findOne(ns(), Query())),
+ ASSERT_EQUALS(mutablebson::unordered(_client.findOne(ns(), BSONObj{} /*filter*/)),
mutablebson::unordered(fromjson("{'_id':0,f:{g:{a:{b:2},h:{b:3}}}}")));
}
};
@@ -476,10 +480,11 @@ public:
void run() {
_client.insert(ns(), fromjson("{'_id':0,z:[4,'b']}"));
_client.update(ns(),
- Query(),
+ BSONObj{} /*filter*/,
BSON("$set" << BSON("z.0"
<< "a")));
- ASSERT_BSONOBJ_EQ(_client.findOne(ns(), Query()), fromjson("{'_id':0,z:['a','b']}"));
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), BSONObj{} /*filter*/),
+ fromjson("{'_id':0,z:['a','b']}"));
}
};
@@ -487,8 +492,9 @@ class AttemptEmbedInExistingNum : public SetBase {
public:
void run() {
_client.insert(ns(), fromjson("{'_id':0,a:1}"));
- _client.update(ns(), Query(), BSON("$set" << BSON("a.b" << 1)));
- ASSERT(_client.findOne(ns(), Query()).woCompare(fromjson("{'_id':0,a:1}")) == 0);
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$set" << BSON("a.b" << 1)));
+ ASSERT(_client.findOne(ns(), BSONObj{} /*filter*/).woCompare(fromjson("{'_id':0,a:1}")) ==
+ 0);
}
};
@@ -496,8 +502,8 @@ class AttemptEmbedConflictsWithOtherSet : public SetBase {
public:
void run() {
_client.insert(ns(), fromjson("{'_id':0}"));
- _client.update(ns(), Query(), BSON("$set" << BSON("a" << 2 << "a.b" << 1)));
- ASSERT_BSONOBJ_EQ(_client.findOne(ns(), Query()), fromjson("{'_id':0}"));
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$set" << BSON("a" << 2 << "a.b" << 1)));
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), BSONObj{} /*filter*/), fromjson("{'_id':0}"));
}
};
@@ -505,8 +511,10 @@ class ModMasksEmbeddedConflict : public SetBase {
public:
void run() {
_client.insert(ns(), fromjson("{'_id':0,a:{b:2}}"));
- _client.update(ns(), Query(), BSON("$set" << BSON("a" << 2 << "a.b" << 1)));
- ASSERT(_client.findOne(ns(), Query()).woCompare(fromjson("{'_id':0,a:{b:2}}")) == 0);
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$set" << BSON("a" << 2 << "a.b" << 1)));
+ ASSERT(
+ _client.findOne(ns(), BSONObj{} /*filter*/).woCompare(fromjson("{'_id':0,a:{b:2}}")) ==
+ 0);
}
};
@@ -514,23 +522,26 @@ class ModOverwritesExistingObject : public SetBase {
public:
void run() {
_client.insert(ns(), fromjson("{'_id':0,a:{b:2}}"));
- _client.update(ns(), Query(), BSON("$set" << BSON("a" << BSON("c" << 2))));
- ASSERT(_client.findOne(ns(), Query()).woCompare(fromjson("{'_id':0,a:{c:2}}")) == 0);
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$set" << BSON("a" << BSON("c" << 2))));
+ ASSERT(
+ _client.findOne(ns(), BSONObj{} /*filter*/).woCompare(fromjson("{'_id':0,a:{c:2}}")) ==
+ 0);
}
};
class InvalidEmbeddedSet : public Fail {
public:
virtual BSONObj doIt() {
- return _client.updateAcknowledged(ns(), Query(), BSON("$set" << BSON("a." << 1)));
+ return _client.updateAcknowledged(
+ ns(), BSONObj{} /*filter*/, BSON("$set" << BSON("a." << 1)));
}
};
class UpsertMissingEmbedded : public SetBase {
public:
void run() {
- _client.update(ns(), Query(), BSON("$set" << BSON("a.b" << 1)), true);
- ASSERT(!_client.findOne(ns(), QUERY("a.b" << 1)).isEmpty());
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$set" << BSON("a.b" << 1)), true);
+ ASSERT(!_client.findOne(ns(), BSON("a.b" << 1)).isEmpty());
}
};
@@ -538,8 +549,9 @@ class Push : public SetBase {
public:
void run() {
_client.insert(ns(), fromjson("{'_id':0,a:[1]}"));
- _client.update(ns(), Query(), BSON("$push" << BSON("a" << 5)));
- ASSERT_BSONOBJ_EQ(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[1,5]}"));
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("a" << 5)));
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), BSONObj{} /*filter*/),
+ fromjson("{'_id':0,a:[1,5]}"));
}
};
@@ -547,8 +559,9 @@ class PushInvalidEltType : public SetBase {
public:
void run() {
_client.insert(ns(), fromjson("{'_id':0,a:1}"));
- _client.update(ns(), Query(), BSON("$push" << BSON("a" << 5)));
- ASSERT(_client.findOne(ns(), Query()).woCompare(fromjson("{'_id':0,a:1}")) == 0);
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("a" << 5)));
+ ASSERT(_client.findOne(ns(), BSONObj{} /*filter*/).woCompare(fromjson("{'_id':0,a:1}")) ==
+ 0);
}
};
@@ -556,8 +569,11 @@ class PushConflictsWithOtherMod : public SetBase {
public:
void run() {
_client.insert(ns(), fromjson("{'_id':0,a:[1]}"));
- _client.update(ns(), Query(), BSON("$set" << BSON("a" << 1) << "$push" << BSON("a" << 5)));
- ASSERT(_client.findOne(ns(), Query()).woCompare(fromjson("{'_id':0,a:[1]}")) == 0);
+ _client.update(ns(),
+ BSONObj{} /*filter*/,
+ BSON("$set" << BSON("a" << 1) << "$push" << BSON("a" << 5)));
+ ASSERT(_client.findOne(ns(), BSONObj{} /*filter*/).woCompare(fromjson("{'_id':0,a:[1]}")) ==
+ 0);
}
};
@@ -565,8 +581,8 @@ class PushFromNothing : public SetBase {
public:
void run() {
_client.insert(ns(), fromjson("{'_id':0}"));
- _client.update(ns(), Query(), BSON("$push" << BSON("a" << 5)));
- ASSERT_BSONOBJ_EQ(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[5]}"));
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("a" << 5)));
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), BSONObj{} /*filter*/), fromjson("{'_id':0,a:[5]}"));
}
};
@@ -574,8 +590,9 @@ class PushFromEmpty : public SetBase {
public:
void run() {
_client.insert(ns(), fromjson("{'_id':0,a:[]}"));
- _client.update(ns(), Query(), BSON("$push" << BSON("a" << 5)));
- ASSERT(_client.findOne(ns(), Query()).woCompare(fromjson("{'_id':0,a:[5]}")) == 0);
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("a" << 5)));
+ ASSERT(_client.findOne(ns(), BSONObj{} /*filter*/).woCompare(fromjson("{'_id':0,a:[5]}")) ==
+ 0);
}
};
@@ -583,8 +600,9 @@ class PushInsideNothing : public SetBase {
public:
void run() {
_client.insert(ns(), fromjson("{'_id':0}"));
- _client.update(ns(), Query(), BSON("$push" << BSON("a.b" << 5)));
- ASSERT(_client.findOne(ns(), Query()).woCompare(fromjson("{'_id':0,a:{b:[5]}}")) == 0);
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("a.b" << 5)));
+ ASSERT(_client.findOne(ns(), BSONObj{} /*filter*/)
+ .woCompare(fromjson("{'_id':0,a:{b:[5]}}")) == 0);
}
};
@@ -592,9 +610,10 @@ class CantPushInsideOtherMod : public SetBase {
public:
void run() {
_client.insert(ns(), fromjson("{'_id':0}"));
- _client.update(
- ns(), Query(), BSON("$set" << BSON("a" << BSONObj()) << "$push" << BSON("a.b" << 5)));
- ASSERT(_client.findOne(ns(), Query()).woCompare(fromjson("{'_id':0}")) == 0);
+ _client.update(ns(),
+ BSONObj{} /*filter*/,
+ BSON("$set" << BSON("a" << BSONObj()) << "$push" << BSON("a.b" << 5)));
+ ASSERT(_client.findOne(ns(), BSONObj{} /*filter*/).woCompare(fromjson("{'_id':0}")) == 0);
}
};
@@ -602,8 +621,11 @@ class CantPushTwice : public SetBase {
public:
void run() {
_client.insert(ns(), fromjson("{'_id':0,a:[]}"));
- _client.update(ns(), Query(), BSON("$push" << BSON("a" << 4) << "$push" << BSON("a" << 5)));
- ASSERT(_client.findOne(ns(), Query()).woCompare(fromjson("{'_id':0,a:[]}")) == 0);
+ _client.update(ns(),
+ BSONObj{} /*filter*/,
+ BSON("$push" << BSON("a" << 4) << "$push" << BSON("a" << 5)));
+ ASSERT(_client.findOne(ns(), BSONObj{} /*filter*/).woCompare(fromjson("{'_id':0,a:[]}")) ==
+ 0);
}
};
@@ -611,8 +633,10 @@ class SetEncapsulationConflictsWithExistingType : public SetBase {
public:
void run() {
_client.insert(ns(), fromjson("{'_id':0,a:{b:4}}"));
- _client.update(ns(), Query(), BSON("$set" << BSON("a.b.c" << 4.0)));
- ASSERT(_client.findOne(ns(), Query()).woCompare(fromjson("{'_id':0,a:{b:4}}")) == 0);
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$set" << BSON("a.b.c" << 4.0)));
+ ASSERT(
+ _client.findOne(ns(), BSONObj{} /*filter*/).woCompare(fromjson("{'_id':0,a:{b:4}}")) ==
+ 0);
}
};
@@ -620,8 +644,10 @@ class CantPushToParent : public SetBase {
public:
void run() {
_client.insert(ns(), fromjson("{'_id':0,a:{b:4}}"));
- _client.update(ns(), Query(), BSON("$push" << BSON("a" << 4.0)));
- ASSERT(_client.findOne(ns(), Query()).woCompare(fromjson("{'_id':0,a:{b:4}}")) == 0);
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("a" << 4.0)));
+ ASSERT(
+ _client.findOne(ns(), BSONObj{} /*filter*/).woCompare(fromjson("{'_id':0,a:{b:4}}")) ==
+ 0);
}
};
@@ -631,8 +657,9 @@ public:
_client.insert(ns(), fromjson("{'_id':0,a:[1]}"));
// { $push : { a : { $each : [ 2, 3 ] } } }
BSONObj pushObj = BSON("$each" << BSON_ARRAY(2 << 3));
- _client.update(ns(), Query(), BSON("$push" << BSON("a" << pushObj)));
- ASSERT_BSONOBJ_EQ(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[1,2,3]}"));
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("a" << pushObj)));
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), BSONObj{} /*filter*/),
+ fromjson("{'_id':0,a:[1,2,3]}"));
}
};
@@ -642,8 +669,9 @@ public:
_client.insert(ns(), fromjson("{'_id':0,a:[]}"));
// { $push : { a : { $each : [ 1, 2, 3 ] } } }
BSONObj pushObj = BSON("$each" << BSON_ARRAY(1 << 2 << 3));
- _client.update(ns(), Query(), BSON("$push" << BSON("a" << pushObj)));
- ASSERT_BSONOBJ_EQ(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[1,2,3]}"));
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("a" << pushObj)));
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), BSONObj{} /*filter*/),
+ fromjson("{'_id':0,a:[1,2,3]}"));
}
};
@@ -653,8 +681,9 @@ public:
_client.insert(ns(), fromjson("{'_id':0,a:[1]}"));
// { $push : { a : { $each : [ 2 ] , $slice : -3 } } }
BSONObj pushObj = BSON("$each" << BSON_ARRAY(2) << "$slice" << -3);
- _client.update(ns(), Query(), BSON("$push" << BSON("a" << pushObj)));
- ASSERT_BSONOBJ_EQ(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[1,2]}"));
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("a" << pushObj)));
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), BSONObj{} /*filter*/),
+ fromjson("{'_id':0,a:[1,2]}"));
}
};
@@ -664,8 +693,9 @@ public:
_client.insert(ns(), fromjson("{'_id':0,a:[1]}"));
// { $push : { a : { $each : [ 2 ] , $slice : -2 } } }
BSONObj pushObj = BSON("$each" << BSON_ARRAY(2) << "$slice" << -2);
- _client.update(ns(), Query(), BSON("$push" << BSON("a" << pushObj)));
- ASSERT_BSONOBJ_EQ(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[1,2]}"));
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("a" << pushObj)));
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), BSONObj{} /*filter*/),
+ fromjson("{'_id':0,a:[1,2]}"));
}
};
@@ -675,8 +705,9 @@ public:
_client.insert(ns(), fromjson("{'_id':0,a:[1]}"));
// { $push : { a : { $each : [ 2 , 3 ] , $slice : -2 } } }
BSONObj pushObj = BSON("$each" << BSON_ARRAY(2 << 3) << "$slice" << -2);
- _client.update(ns(), Query(), BSON("$push" << BSON("a" << pushObj)));
- ASSERT_BSONOBJ_EQ(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[2,3]}"));
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("a" << pushObj)));
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), BSONObj{} /*filter*/),
+ fromjson("{'_id':0,a:[2,3]}"));
}
};
@@ -686,8 +717,9 @@ public:
_client.insert(ns(), fromjson("{'_id':0,a:[1,2]}"));
// { $push : { a : { $each : [ 3 ] , $slice : -2 } } }
BSONObj pushObj = BSON("$each" << BSON_ARRAY(3) << "$slice" << -2);
- _client.update(ns(), Query(), BSON("$push" << BSON("a" << pushObj)));
- ASSERT_BSONOBJ_EQ(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[2,3]}"));
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("a" << pushObj)));
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), BSONObj{} /*filter*/),
+ fromjson("{'_id':0,a:[2,3]}"));
}
};
@@ -697,8 +729,8 @@ public:
_client.insert(ns(), fromjson("{'_id':0,a:[1,2]}"));
// { $push : { a : { $each : [ 3 ] , $slice : 0 } } }
BSONObj pushObj = BSON("$each" << BSON_ARRAY(3) << "$slice" << 0);
- _client.update(ns(), Query(), BSON("$push" << BSON("a" << pushObj)));
- ASSERT_BSONOBJ_EQ(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[]}"));
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("a" << pushObj)));
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), BSONObj{} /*filter*/), fromjson("{'_id':0,a:[]}"));
}
};
@@ -708,8 +740,8 @@ public:
_client.insert(ns(), fromjson("{'_id':0}"));
// { $push : { a : { $each : [ 3 ] , $slice : 0 } } }
BSONObj pushObj = BSON("$each" << BSON_ARRAY(3) << "$slice" << 0);
- _client.update(ns(), Query(), BSON("$push" << BSON("a" << pushObj)));
- ASSERT_BSONOBJ_EQ(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[]}"));
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("a" << pushObj)));
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), BSONObj{} /*filter*/), fromjson("{'_id':0,a:[]}"));
}
};
@@ -719,8 +751,9 @@ public:
_client.insert(ns(), fromjson("{'_id':0}"));
// { $push : { a : { $each : [ 1 , 2 ] , $slice : -3 } } }
BSONObj pushObj = BSON("$each" << BSON_ARRAY(1 << 2) << "$slice" << -3);
- _client.update(ns(), Query(), BSON("$push" << BSON("a" << pushObj)));
- ASSERT_BSONOBJ_EQ(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[1,2]}"));
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("a" << pushObj)));
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), BSONObj{} /*filter*/),
+ fromjson("{'_id':0,a:[1,2]}"));
}
};
@@ -730,8 +763,9 @@ public:
_client.insert(ns(), fromjson("{'_id':0}"));
// { $push : { a : { $each : [ 1 , 2 , 3 ] , $slice : -2 } } }
BSONObj pushObj = BSON("$each" << BSON_ARRAY(1 << 2 << 3) << "$slice" << -2);
- _client.update(ns(), Query(), BSON("$push" << BSON("a" << pushObj)));
- ASSERT_BSONOBJ_EQ(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[2,3]}"));
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("a" << pushObj)));
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), BSONObj{} /*filter*/),
+ fromjson("{'_id':0,a:[2,3]}"));
}
};
@@ -741,8 +775,8 @@ public:
_client.insert(ns(), fromjson("{'_id':0,a:[]}"));
// { $push : { a : { $each : [ 1 ] , $slice : -3 } } }
BSONObj pushObj = BSON("$each" << BSON_ARRAY(1) << "$slice" << -3);
- _client.update(ns(), Query(), BSON("$push" << BSON("a" << pushObj)));
- ASSERT_BSONOBJ_EQ(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[1]}"));
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("a" << pushObj)));
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), BSONObj{} /*filter*/), fromjson("{'_id':0,a:[1]}"));
}
};
@@ -752,8 +786,9 @@ public:
_client.insert(ns(), fromjson("{'_id':0,a:[]}"));
// { $push : { a : { $each : [ 1 , 2 , 3 ] , $slice : -2 } } }
BSONObj pushObj = BSON("$each" << BSON_ARRAY(1 << 2 << 3) << "$slice" << -2);
- _client.update(ns(), Query(), BSON("$push" << BSON("a" << pushObj)));
- ASSERT_BSONOBJ_EQ(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[2,3]}"));
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("a" << pushObj)));
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), BSONObj{} /*filter*/),
+ fromjson("{'_id':0,a:[2,3]}"));
}
};
@@ -764,8 +799,10 @@ public:
// { $push: { a: { $each: [ 5 ] , $slice : -2 }, { b: $each: [ 6 ] , $slice: -1 } } }
BSONObj objA = BSON("$each" << BSON_ARRAY(5) << "$slice" << -2);
BSONObj objB = BSON("$each" << BSON_ARRAY(6) << "$slice" << -1);
- _client.update(ns(), Query(), BSON("$push" << BSON("a" << objA << "b" << objB)));
- ASSERT_BSONOBJ_EQ(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[2,5],b:[6]}"));
+ _client.update(
+ ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("a" << objA << "b" << objB)));
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), BSONObj{} /*filter*/),
+ fromjson("{'_id':0,a:[2,5],b:[6]}"));
}
};
@@ -775,8 +812,9 @@ public:
_client.insert(ns(), fromjson("{'_id':0,a:[1,2],b:[3]}"));
// { $push : { a : { $each : [ 5 ] , $slice : -2 } , { b : 4 } }
BSONObj objA = BSON("$each" << BSON_ARRAY(5) << "$slice" << -2);
- _client.update(ns(), Query(), BSON("$push" << BSON("a" << objA << "b" << 4)));
- ASSERT_BSONOBJ_EQ(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[2,5],b:[3,4]}"));
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("a" << objA << "b" << 4)));
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), BSONObj{} /*filter*/),
+ fromjson("{'_id':0,a:[2,5],b:[3,4]}"));
}
};
@@ -787,8 +825,10 @@ public:
// { $push: { a: { $each: [ 5 ] , $slice: -2 } , { a: $each: [ 6 ] , $slice: -1 } } }
BSONObj objA = BSON("$each" << BSON_ARRAY(5) << "$slice" << -2);
BSONObj other = BSON("$each" << BSON_ARRAY(6) << "$slice" << -1);
- _client.update(ns(), Query(), BSON("$push" << BSON("a" << objA << "a" << other)));
- ASSERT(_client.findOne(ns(), Query()).woCompare(fromjson("{'_id':0,a:[1],b:[3]}")) == 0);
+ _client.update(
+ ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("a" << objA << "a" << other)));
+ ASSERT(_client.findOne(ns(), BSONObj{} /*filter*/)
+ .woCompare(fromjson("{'_id':0,a:[1],b:[3]}")) == 0);
}
};
@@ -798,8 +838,9 @@ public:
_client.insert(ns(), fromjson("{'_id':0,a:[1],b:[3]}"));
// { $push : { a : { $each : [ 5 ] , $slice : -2 } , { a : 4 } } }
BSONObj objA = BSON("$each" << BSON_ARRAY(5) << "$slice" << -2);
- _client.update(ns(), Query(), BSON("$push" << BSON("a" << objA << "a" << 4)));
- ASSERT(_client.findOne(ns(), Query()).woCompare(fromjson("{'_id':0,a:[1],b:[3]}")) == 0);
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("a" << objA << "a" << 4)));
+ ASSERT(_client.findOne(ns(), BSONObj{} /*filter*/)
+ .woCompare(fromjson("{'_id':0,a:[1],b:[3]}")) == 0);
}
};
@@ -809,8 +850,10 @@ public:
_client.insert(ns(), fromjson("{'_id':0,a:[1,2]}"));
// { $push : { a : { $each : 3 , $slice : -2 } } }
BSONObj pushObj = BSON("$each" << 3 << "$slice" << -2);
- _client.update(ns(), Query(), BSON("$push" << BSON("a" << pushObj)));
- ASSERT(_client.findOne(ns(), Query()).woCompare(fromjson("{'_id':0,a:[1,2]}")) == 0);
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("a" << pushObj)));
+ ASSERT(
+ _client.findOne(ns(), BSONObj{} /*filter*/).woCompare(fromjson("{'_id':0,a:[1,2]}")) ==
+ 0);
}
};
@@ -820,8 +863,10 @@ public:
_client.insert(ns(), fromjson("{'_id':0,a:[1,2]}"));
// { $push : { a : { $each : [ 3 ], $slice : [ -2 ] } } }
BSONObj pushObj = BSON("$each" << BSON_ARRAY(3) << "$slice" << BSON_ARRAY(-2));
- _client.update(ns(), Query(), BSON("$push" << BSON("a" << pushObj)));
- ASSERT(_client.findOne(ns(), Query()).woCompare(fromjson("{'_id':0,a:[1,2]}")) == 0);
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("a" << pushObj)));
+ ASSERT(
+ _client.findOne(ns(), BSONObj{} /*filter*/).woCompare(fromjson("{'_id':0,a:[1,2]}")) ==
+ 0);
}
};
@@ -831,8 +876,10 @@ public:
_client.insert(ns(), fromjson("{'_id':0,a:[1,2]}"));
// { $push : { a : { $each : [ 3 ], $slice : 2 } } }
BSONObj pushObj = BSON("$each" << BSON_ARRAY(3) << "$slice" << 2);
- _client.update(ns(), Query(), BSON("$push" << BSON("a" << pushObj)));
- ASSERT(_client.findOne(ns(), Query()).woCompare(fromjson("{'_id':0,a:[1,2]}")) == 0);
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("a" << pushObj)));
+ ASSERT(
+ _client.findOne(ns(), BSONObj{} /*filter*/).woCompare(fromjson("{'_id':0,a:[1,2]}")) ==
+ 0);
}
};
@@ -843,8 +890,10 @@ public:
_client.insert(ns(), fromjson("{'_id':0,a:[1,2]}"));
// { $push : { a : { $each : [ 3 ], $slice : -2.1 } } }
BSONObj pushObj = BSON("$each" << BSON_ARRAY(3) << "$slice" << -2.1);
- _client.update(ns(), Query(), BSON("$push" << BSON("a" << pushObj)));
- ASSERT(_client.findOne(ns(), Query()).woCompare(fromjson("{'_id':0,a:[1,2]}")) == 0);
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("a" << pushObj)));
+ ASSERT(
+ _client.findOne(ns(), BSONObj{} /*filter*/).woCompare(fromjson("{'_id':0,a:[1,2]}")) ==
+ 0);
}
};
@@ -854,8 +903,9 @@ public:
_client.insert(ns(), fromjson("{'_id':0,a:[1,2]}"));
// { $push : { a : { $each : [ 3 ], $slice : -2.0 } } }
BSONObj pushObj = BSON("$each" << BSON_ARRAY(3) << "$slice" << -2.0);
- _client.update(ns(), Query(), BSON("$push" << BSON("a" << pushObj)));
- ASSERT_BSONOBJ_EQ(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[2,3]}"));
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("a" << pushObj)));
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), BSONObj{} /*filter*/),
+ fromjson("{'_id':0,a:[2,3]}"));
}
};
@@ -865,8 +915,10 @@ public:
_client.insert(ns(), fromjson("{'_id':0,a:[1,2]}"));
// { $push : { a : { $each : [ 3 ], $xxxx : 2 } } }
BSONObj pushObj = BSON("$each" << BSON_ARRAY(3) << "$xxxx" << 2);
- _client.update(ns(), Query(), BSON("$push" << BSON("a" << pushObj)));
- ASSERT(_client.findOne(ns(), Query()).woCompare(fromjson("{'_id':0,a:[1,2]}")) == 0);
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("a" << pushObj)));
+ ASSERT(
+ _client.findOne(ns(), BSONObj{} /*filter*/).woCompare(fromjson("{'_id':0,a:[1,2]}")) ==
+ 0);
}
};
@@ -955,8 +1007,8 @@ protected:
void check(BSONObj expected) {
std::cout << expected.toString() << std::endl;
- std::cout << _client.findOne(ns(), Query()) << std::endl;
- ASSERT(_client.findOne(ns(), Query()).woCompare(expected) == 0);
+ std::cout << _client.findOne(ns(), BSONObj{} /*filter*/) << std::endl;
+ ASSERT(_client.findOne(ns(), BSONObj{} /*filter*/).woCompare(expected) == 0);
}
private:
@@ -993,16 +1045,16 @@ public:
switch (i) {
case TOPK_ASC:
case BOTTOMK_ASC:
- _client.update(ns(), Query(), getUpdate(i));
- result = _client.findOne(ns(), Query());
+ _client.update(ns(), BSONObj{} /*filter*/, getUpdate(i));
+ result = _client.findOne(ns(), BSONObj{} /*filter*/);
expected = fromjson("{'_id':0,x:[{a:1,b:1},{a:2,b:2}]}");
ASSERT_BSONOBJ_EQ(result, expected);
break;
case TOPK_DESC:
case BOTTOMK_DESC:
- _client.update(ns(), Query(), getUpdate(i));
- result = _client.findOne(ns(), Query());
+ _client.update(ns(), BSONObj{} /*filter*/, getUpdate(i));
+ result = _client.findOne(ns(), BSONObj{} /*filter*/);
expected = fromjson("{'_id':0,x:[{a:2,b:2},{a:1,b:1}]}");
ASSERT_BSONOBJ_EQ(result, expected);
break;
@@ -1038,16 +1090,16 @@ public:
switch (i) {
case TOPK_ASC:
case BOTTOMK_ASC:
- _client.update(ns(), Query(), getUpdate(i));
- result = _client.findOne(ns(), Query());
+ _client.update(ns(), BSONObj{} /*filter*/, getUpdate(i));
+ result = _client.findOne(ns(), BSONObj{} /*filter*/);
expected = fromjson("{'_id':0,x:[{a:1,b:1},{a:2,b:2}]}");
ASSERT_BSONOBJ_EQ(result, expected);
break;
case TOPK_DESC:
case BOTTOMK_DESC:
- _client.update(ns(), Query(), getUpdate(i));
- result = _client.findOne(ns(), Query());
+ _client.update(ns(), BSONObj{} /*filter*/, getUpdate(i));
+ result = _client.findOne(ns(), BSONObj{} /*filter*/);
expected = fromjson("{'_id':0,x:[{a:2,b:2},{a:1,b:1}]}");
ASSERT_BSONOBJ_EQ(result, expected);
break;
@@ -1082,15 +1134,15 @@ public:
BSONObj expected;
switch (i) {
case TOPK_ASC:
- _client.update(ns(), Query(), getUpdate(i));
- result = _client.findOne(ns(), Query());
+ _client.update(ns(), BSONObj{} /*filter*/, getUpdate(i));
+ result = _client.findOne(ns(), BSONObj{} /*filter*/);
expected = fromjson("{'_id':0,x:[{a:2,b:2},{a:3,b:3}]}");
ASSERT_BSONOBJ_EQ(result, expected);
break;
case TOPK_DESC:
- _client.update(ns(), Query(), getUpdate(i));
- result = _client.findOne(ns(), Query());
+ _client.update(ns(), BSONObj{} /*filter*/, getUpdate(i));
+ result = _client.findOne(ns(), BSONObj{} /*filter*/);
expected = fromjson("{'_id':0,x:[{a:2,b:2},{a:1,b:1}]}");
ASSERT_BSONOBJ_EQ(result, expected);
break;
@@ -1129,8 +1181,8 @@ public:
BSONObj result;
BSONObj expected;
- _client.update(ns(), Query(), getUpdate(i));
- result = _client.findOne(ns(), Query());
+ _client.update(ns(), BSONObj{} /*filter*/, getUpdate(i));
+ result = _client.findOne(ns(), BSONObj{} /*filter*/);
expected = fromjson("{'_id':0,x:[]}");
ASSERT_BSONOBJ_EQ(result, expected);
}
@@ -1162,8 +1214,8 @@ public:
BSONObj result;
BSONObj expected;
- _client.update(ns(), Query(), getUpdate(i));
- result = _client.findOne(ns(), Query());
+ _client.update(ns(), BSONObj{} /*filter*/, getUpdate(i));
+ result = _client.findOne(ns(), BSONObj{} /*filter*/);
expected = fromjson("{'_id':0,x:[]}");
ASSERT_BSONOBJ_EQ(result, expected);
}
@@ -1199,16 +1251,16 @@ public:
switch (i) {
case TOPK_ASC:
case BOTTOMK_ASC:
- _client.update(ns(), Query(), getUpdate(i));
- result = _client.findOne(ns(), Query());
+ _client.update(ns(), BSONObj{} /*filter*/, getUpdate(i));
+ result = _client.findOne(ns(), BSONObj{} /*filter*/);
expected = fromjson("{'_id':0,x:[{a:1,b:1},{a:2,b:2}]}");
ASSERT_BSONOBJ_EQ(result, expected);
break;
case TOPK_DESC:
case BOTTOMK_DESC:
- _client.update(ns(), Query(), getUpdate(i));
- result = _client.findOne(ns(), Query());
+ _client.update(ns(), BSONObj{} /*filter*/, getUpdate(i));
+ result = _client.findOne(ns(), BSONObj{} /*filter*/);
expected = fromjson("{'_id':0,x:[{a:2,b:2},{a:1,b:1}]}");
ASSERT_BSONOBJ_EQ(result, expected);
break;
@@ -1244,15 +1296,15 @@ public:
BSONObj expected;
switch (i) {
case TOPK_ASC:
- _client.update(ns(), Query(), getUpdate(i));
- result = _client.findOne(ns(), Query());
+ _client.update(ns(), BSONObj{} /*filter*/, getUpdate(i));
+ result = _client.findOne(ns(), BSONObj{} /*filter*/);
expected = fromjson("{'_id':0,x:[{a:2,b:2},{a:3,b:3}]}");
ASSERT_BSONOBJ_EQ(result, expected);
break;
case TOPK_DESC:
- _client.update(ns(), Query(), getUpdate(i));
- result = _client.findOne(ns(), Query());
+ _client.update(ns(), BSONObj{} /*filter*/, getUpdate(i));
+ result = _client.findOne(ns(), BSONObj{} /*filter*/);
expected = fromjson("{'_id':0,x:[{a:2,b:2},{a:1,b:1}]}");
ASSERT_BSONOBJ_EQ(result, expected);
break;
@@ -1294,16 +1346,16 @@ public:
switch (i) {
case TOPK_ASC:
case BOTTOMK_ASC:
- _client.update(ns(), Query(), getUpdate(i));
- result = _client.findOne(ns(), Query());
+ _client.update(ns(), BSONObj{} /*filter*/, getUpdate(i));
+ result = _client.findOne(ns(), BSONObj{} /*filter*/);
expected = fromjson("{'_id':0,x:[{a:1,b:1},{a:2,b:2}]}");
ASSERT_BSONOBJ_EQ(result, expected);
break;
case TOPK_DESC:
case BOTTOMK_DESC:
- _client.update(ns(), Query(), getUpdate(i));
- result = _client.findOne(ns(), Query());
+ _client.update(ns(), BSONObj{} /*filter*/, getUpdate(i));
+ result = _client.findOne(ns(), BSONObj{} /*filter*/);
expected = fromjson("{'_id':0,x:[{a:2,b:2},{a:1,b:1}]}");
ASSERT_BSONOBJ_EQ(result, expected);
break;
@@ -1339,15 +1391,15 @@ public:
BSONObj expected;
switch (i) {
case TOPK_ASC:
- _client.update(ns(), Query(), getUpdate(i));
- result = _client.findOne(ns(), Query());
+ _client.update(ns(), BSONObj{} /*filter*/, getUpdate(i));
+ result = _client.findOne(ns(), BSONObj{} /*filter*/);
expected = fromjson("{'_id':0,x:[{a:2,b:2},{a:3,b:3}]}");
ASSERT_BSONOBJ_EQ(result, expected);
break;
case TOPK_DESC:
- _client.update(ns(), Query(), getUpdate(i));
- result = _client.findOne(ns(), Query());
+ _client.update(ns(), BSONObj{} /*filter*/, getUpdate(i));
+ result = _client.findOne(ns(), BSONObj{} /*filter*/);
expected = fromjson("{'_id':0,x:[{a:2,b:2},{a:1,b:1}]}");
ASSERT_BSONOBJ_EQ(result, expected);
break;
@@ -1507,37 +1559,37 @@ public:
// { $push : { x : { $each : [ {a:3} ], $slice:-2, $sort : {a..d:1} } } }
BSONObj pushObj = BSON("$each" << BSON_ARRAY(BSON("a" << 3)) << "$slice" << -2 << "$sort"
<< BSON("a..d" << 1));
- _client.update(ns(), Query(), BSON("$push" << BSON("x" << pushObj)));
- BSONObj result = _client.findOne(ns(), Query());
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("x" << pushObj)));
+ BSONObj result = _client.findOne(ns(), BSONObj{} /*filter*/);
ASSERT_BSONOBJ_EQ(result, expected);
// { $push : { x : { $each : [ {a:3} ], $slice:-2, $sort : {a.:1} } } }
pushObj = BSON("$each" << BSON_ARRAY(BSON("a" << 3)) << "$slice" << -2 << "$sort"
<< BSON("a." << 1));
- _client.update(ns(), Query(), BSON("$push" << BSON("x" << pushObj)));
- result = _client.findOne(ns(), Query());
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("x" << pushObj)));
+ result = _client.findOne(ns(), BSONObj{} /*filter*/);
ASSERT_BSONOBJ_EQ(result, expected);
// { $push : { x : { $each : [ {a:3} ], $slice:-2, $sort : {.b:1} } } }
pushObj = BSON("$each" << BSON_ARRAY(BSON("a" << 3)) << "$slice" << -2 << "$sort"
<< BSON(".b" << 1));
- _client.update(ns(), Query(), BSON("$push" << BSON("x" << pushObj)));
- result = _client.findOne(ns(), Query());
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("x" << pushObj)));
+ result = _client.findOne(ns(), BSONObj{} /*filter*/);
ASSERT_BSONOBJ_EQ(result, expected);
// { $push : { x : { $each : [ {a:3} ], $slice:-2, $sort : {.:1} } } }
pushObj = BSON("$each" << BSON_ARRAY(BSON("a" << 3)) << "$slice" << -2 << "$sort"
<< BSON("." << 1));
- _client.update(ns(), Query(), BSON("$push" << BSON("x" << pushObj)));
- result = _client.findOne(ns(), Query());
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("x" << pushObj)));
+ result = _client.findOne(ns(), BSONObj{} /*filter*/);
ASSERT_BSONOBJ_EQ(result, expected);
// { $push : { x : { $each : [ {a:3} ], $slice:-2, $sort : {'':1} } } }
pushObj = BSON("$each" << BSON_ARRAY(BSON("a" << 3)) << "$slice" << -2 << "$sort"
<< BSON("" << 1));
- _client.update(ns(), Query(), BSON("$push" << BSON("x" << pushObj)));
- result = _client.findOne(ns(), Query());
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("x" << pushObj)));
+ result = _client.findOne(ns(), BSONObj{} /*filter*/);
ASSERT_BSONOBJ_EQ(result, expected);
}
};
@@ -1550,8 +1602,8 @@ public:
// { $push : { x : { $each : [ 3 ], $slice:-2, $sort : {a:1} } } }
BSONObj pushObj =
BSON("$each" << BSON_ARRAY(3) << "$slice" << -2 << "$sort" << BSON("a" << 1));
- _client.update(ns(), Query(), BSON("$push" << BSON("x" << pushObj)));
- BSONObj result = _client.findOne(ns(), Query());
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("x" << pushObj)));
+ BSONObj result = _client.findOne(ns(), BSONObj{} /*filter*/);
ASSERT_BSONOBJ_EQ(result, expected);
}
};
@@ -1564,8 +1616,8 @@ public:
// { $push : { x : { $each : [ {a:3} ], $slice:-2, $sort : 2} } }
BSONObj pushObj =
BSON("$each" << BSON_ARRAY(BSON("a" << 3)) << "$slice" << -2 << "$sort" << 2);
- _client.update(ns(), Query(), BSON("$push" << BSON("x" << pushObj)));
- BSONObj result = _client.findOne(ns(), Query());
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("x" << pushObj)));
+ BSONObj result = _client.findOne(ns(), BSONObj{} /*filter*/);
ASSERT_BSONOBJ_EQ(result, expected);
}
};
@@ -1578,8 +1630,8 @@ public:
// { $push : { x : { $each : [ {a:3} ], $slice:2, $sort : {a:1} } } }
BSONObj pushObj = BSON("$each" << BSON_ARRAY(BSON("a" << 3)) << "$slice" << 2 << "$sort"
<< BSON("a" << 1));
- _client.update(ns(), Query(), BSON("$push" << BSON("x" << pushObj)));
- BSONObj result = _client.findOne(ns(), Query());
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("x" << pushObj)));
+ BSONObj result = _client.findOne(ns(), BSONObj{} /*filter*/);
ASSERT_BSONOBJ_EQ(result, expected);
}
};
@@ -1592,8 +1644,8 @@ public:
// { $push : { x : { $each : [ {a:3} ], $slice:-2.1, $sort : {a:1} } } }
BSONObj pushObj = BSON("$each" << BSON_ARRAY(BSON("a" << 3)) << "$slice" << -2.1 << "$sort"
<< BSON("a" << 1));
- _client.update(ns(), Query(), BSON("$push" << BSON("x" << pushObj)));
- BSONObj result = _client.findOne(ns(), Query());
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("x" << pushObj)));
+ BSONObj result = _client.findOne(ns(), BSONObj{} /*filter*/);
ASSERT_BSONOBJ_EQ(result, expected);
}
};
@@ -1605,9 +1657,9 @@ public:
// { $push : { x : { $each : [ {a:3} ], $slice:-2.0, $sort : {a:1} } } }
BSONObj pushObj = BSON("$each" << BSON_ARRAY(BSON("a" << 3)) << "$slice" << -2.0 << "$sort"
<< BSON("a" << 1));
- _client.update(ns(), Query(), BSON("$push" << BSON("x" << pushObj)));
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("x" << pushObj)));
BSONObj expected = fromjson("{'_id':0,x:[{a:2},{a:3}]}");
- BSONObj result = _client.findOne(ns(), Query());
+ BSONObj result = _client.findOne(ns(), BSONObj{} /*filter*/);
ASSERT_BSONOBJ_EQ(result, expected);
}
};
@@ -1620,8 +1672,8 @@ public:
// { $push : { x : { $each : [ {a:3} ], $slice:-2.0, $sort : [2, 1] } } }
BSONObj pushObj = BSON("$each" << BSON_ARRAY(BSON("a" << 3)) << "$slice" << -2.0 << "$sort"
<< BSON_ARRAY(2 << 1));
- _client.update(ns(), Query(), BSON("$push" << BSON("x" << pushObj)));
- BSONObj result = _client.findOne(ns(), Query());
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("x" << pushObj)));
+ BSONObj result = _client.findOne(ns(), BSONObj{} /*filter*/);
ASSERT_BSONOBJ_EQ(result, expected);
}
};
@@ -1634,8 +1686,8 @@ public:
// { $push : { x : { $each : [ {a:3} ], $slice:-2, $sort : {a:10} } } }
BSONObj pushObj = BSON("$each" << BSON_ARRAY(BSON("a" << 3)) << "$slice" << -2 << "$sort"
<< BSON("a" << 10));
- _client.update(ns(), Query(), BSON("$push" << BSON("x" << pushObj)));
- BSONObj result = _client.findOne(ns(), Query());
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("x" << pushObj)));
+ BSONObj result = _client.findOne(ns(), BSONObj{} /*filter*/);
ASSERT_BSONOBJ_EQ(result, expected);
}
};
@@ -1647,9 +1699,9 @@ public:
// { $push : { x : { $each : [ {a:2} ], $sort: {a:1}, $slice:-2 } } }
BSONObj pushObj = BSON("$each" << BSON_ARRAY(BSON("a" << 2)) << "$sort" << BSON("a" << 1)
<< "$slice" << -2.0);
- _client.update(ns(), Query(), BSON("$push" << BSON("x" << pushObj)));
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("x" << pushObj)));
BSONObj expected = fromjson("{'_id':0,x:[{a:2},{a:3}]}");
- BSONObj result = _client.findOne(ns(), Query());
+ BSONObj result = _client.findOne(ns(), BSONObj{} /*filter*/);
ASSERT_BSONOBJ_EQ(result, expected);
}
};
@@ -1662,8 +1714,8 @@ public:
// { $push : { x : { $each : [ {a:2} ], $sort : {a:1}, $sort: {a:1} } } }
BSONObj pushObj = BSON("$each" << BSON_ARRAY(BSON("a" << 2)) << "$sort" << BSON("a" << 1)
<< "$sort" << BSON("a" << 1));
- _client.update(ns(), Query(), BSON("$push" << BSON("x" << pushObj)));
- BSONObj result = _client.findOne(ns(), Query());
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$push" << BSON("x" << pushObj)));
+ BSONObj result = _client.findOne(ns(), BSONObj{} /*filter*/);
ASSERT_BSONOBJ_EQ(result, expected);
}
};
@@ -1672,8 +1724,10 @@ class CantIncParent : public SetBase {
public:
void run() {
_client.insert(ns(), fromjson("{'_id':0,a:{b:4}}"));
- _client.update(ns(), Query(), BSON("$inc" << BSON("a" << 4.0)));
- ASSERT(_client.findOne(ns(), Query()).woCompare(fromjson("{'_id':0,a:{b:4}}")) == 0);
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$inc" << BSON("a" << 4.0)));
+ ASSERT(
+ _client.findOne(ns(), BSONObj{} /*filter*/).woCompare(fromjson("{'_id':0,a:{b:4}}")) ==
+ 0);
}
};
@@ -1681,8 +1735,9 @@ class DontDropEmpty : public SetBase {
public:
void run() {
_client.insert(ns(), fromjson("{'_id':0,a:{b:{}}}"));
- _client.update(ns(), Query(), BSON("$set" << BSON("a.c" << 4.0)));
- ASSERT(_client.findOne(ns(), Query()).woCompare(fromjson("{'_id':0,a:{b:{},c:4}}")) == 0);
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$set" << BSON("a.c" << 4.0)));
+ ASSERT(_client.findOne(ns(), BSONObj{} /*filter*/)
+ .woCompare(fromjson("{'_id':0,a:{b:{},c:4}}")) == 0);
}
};
@@ -1690,8 +1745,9 @@ class InsertInEmpty : public SetBase {
public:
void run() {
_client.insert(ns(), fromjson("{'_id':0,a:{b:{}}}"));
- _client.update(ns(), Query(), BSON("$set" << BSON("a.b.f" << 4.0)));
- ASSERT(_client.findOne(ns(), Query()).woCompare(fromjson("{'_id':0,a:{b:{f:4}}}")) == 0);
+ _client.update(ns(), BSONObj{} /*filter*/, BSON("$set" << BSON("a.b.f" << 4.0)));
+ ASSERT(_client.findOne(ns(), BSONObj{} /*filter*/)
+ .woCompare(fromjson("{'_id':0,a:{b:{f:4}}}")) == 0);
}
};
@@ -1700,8 +1756,9 @@ public:
void run() {
ASSERT_OK(dbtests::createIndex(&_opCtx, ns(), BSON("a" << 1)));
_client.insert(ns(), fromjson("{'_id':0}"));
- _client.update(ns(), Query(), fromjson("{$set:{'a.b':4}}"));
- ASSERT_BSONOBJ_EQ(fromjson("{'_id':0,a:{b:4}}"), _client.findOne(ns(), Query()));
+ _client.update(ns(), BSONObj{} /*filter*/, fromjson("{$set:{'a.b':4}}"));
+ ASSERT_BSONOBJ_EQ(fromjson("{'_id':0,a:{b:4}}"),
+ _client.findOne(ns(), BSONObj{} /*filter*/));
ASSERT_BSONOBJ_EQ(
fromjson("{'_id':0,a:{b:4}}"),
_client.findOne(ns(), fromjson("{'a.b':4}"))); // make sure the index works
@@ -1713,7 +1770,7 @@ public:
void run() {
_client.insert(ns(), BSON("_id" << 55 << "i" << 5));
_client.update(ns(), BSON("i" << 5), BSON("i" << 6));
- ASSERT(!_client.findOne(ns(), Query(BSON("_id" << 55)).hint("{\"_id\":1}")).isEmpty());
+ ASSERT(!_client.findOne(ns(), BSON("_id" << 55), Query().hint(BSON("_id" << 1))).isEmpty());
}
};
@@ -1722,7 +1779,7 @@ public:
void run() {
_client.update(ns(), BSONObj(), BSON("_id" << 52307 << "$set" << BSON("q" << 3)), true);
ASSERT_BSONOBJ_EQ(fromjson("{'_id':52307,$set:{q:3}}"),
- _client.findOne(ns(), Query(BSON("_id" << 52307))));
+ _client.findOne(ns(), BSON("_id" << 52307)));
}
};
@@ -1731,7 +1788,7 @@ public:
void run() {
_client.insert(ns(), BSON("a" << 5));
_client.update(ns(), BSON("a" << 5), fromjson("{$set:{b:null}}"));
- ASSERT_EQUALS(jstNULL, _client.findOne(ns(), QUERY("a" << 5)).getField("b").type());
+ ASSERT_EQUALS(jstNULL, _client.findOne(ns(), BSON("a" << 5)).getField("b").type());
}
};
@@ -1744,7 +1801,7 @@ public:
_client.update(ns(), BSONObj(), BSON("$set" << BSON("x.b" << 1 << "x.c" << 1)));
ASSERT_BSONOBJ_EQ(BSON("_id" << 0 << "a" << 1 << "x" << BSON("b" << 1 << "c" << 1) << "x"
<< BSONObj() << "z" << 5),
- _client.findOne(ns(), BSONObj()));
+ _client.findOne(ns(), BSONObj{} /*filter*/));
}
};
@@ -1758,7 +1815,7 @@ public:
ns(), BSONObj(), BSON("$set" << BSON("x.b" << 1 << "x.c" << 1 << "x.d" << 1)));
ASSERT_BSONOBJ_EQ(BSON("_id" << 0 << "x" << BSON("b" << 1 << "c" << 1 << "d" << 1) << "x"
<< BSONObj() << "x" << BSONObj()),
- _client.findOne(ns(), BSONObj()));
+ _client.findOne(ns(), BSONObj{} /*filter*/));
}
};
@@ -1768,7 +1825,7 @@ public:
_client.insert(ns(), BSON("_id" << 0 << "x" << 5));
_client.update(ns(), BSONObj(), BSON("$set" << BSON("a" << 1 << "b" << 1 << "x" << 10)));
ASSERT_EQUALS(mutablebson::unordered(BSON("_id" << 0 << "a" << 1 << "b" << 1 << "x" << 10)),
- mutablebson::unordered(_client.findOne(ns(), BSONObj())));
+ mutablebson::unordered(_client.findOne(ns(), BSONObj{} /*filter*/)));
}
};
@@ -1787,7 +1844,7 @@ protected:
}
BSONObj findOne() {
- return _client.findOne(ns(), BSONObj());
+ return _client.findOne(ns(), BSONObj{} /*filter*/);
}
void test(const char* initial, const char* mod, const char* after) {