summaryrefslogtreecommitdiff
path: root/src/mongo/db/update
diff options
context:
space:
mode:
authorJames Wahlin <james@mongodb.com>2017-07-25 08:59:47 -0400
committerJames Wahlin <james@mongodb.com>2017-08-09 16:29:49 -0400
commit2087f94e8c6d7226a4dd48155082034ae51c3cfd (patch)
tree6a6dac53fe93bc29a174e008c26f2d6daf474a05 /src/mongo/db/update
parentc1aee1915536be2d1928d1098e133acbfdc3a575 (diff)
downloadmongo-2087f94e8c6d7226a4dd48155082034ae51c3cfd.tar.gz
SERVER-30046 Support $expr constant expression in ComparisonMatchExpression
Diffstat (limited to 'src/mongo/db/update')
-rw-r--r--src/mongo/db/update/addtoset_node_test.cpp37
-rw-r--r--src/mongo/db/update/arithmetic_node_test.cpp114
-rw-r--r--src/mongo/db/update/bit_node_test.cpp19
-rw-r--r--src/mongo/db/update/compare_node_test.cpp39
-rw-r--r--src/mongo/db/update/current_date_node_test.cpp15
-rw-r--r--src/mongo/db/update/log_builder.cpp3
-rw-r--r--src/mongo/db/update/object_replace_node_test.cpp37
-rw-r--r--src/mongo/db/update/path_support_test.cpp18
-rw-r--r--src/mongo/db/update/pull_node_test.cpp67
-rw-r--r--src/mongo/db/update/pullall_node_test.cpp27
-rw-r--r--src/mongo/db/update/push_node_test.cpp73
-rw-r--r--src/mongo/db/update/push_sorter_test.cpp3
-rw-r--r--src/mongo/db/update/rename_node_test.cpp55
-rw-r--r--src/mongo/db/update/set_node_test.cpp151
-rw-r--r--src/mongo/db/update/unset_node_test.cpp45
-rw-r--r--src/mongo/db/update/update_array_node_test.cpp47
-rw-r--r--src/mongo/db/update/update_driver_test.cpp7
-rw-r--r--src/mongo/db/update/update_object_node_test.cpp53
18 files changed, 398 insertions, 412 deletions
diff --git a/src/mongo/db/update/addtoset_node_test.cpp b/src/mongo/db/update/addtoset_node_test.cpp
index 816cccf4899..c8440764c38 100644
--- a/src/mongo/db/update/addtoset_node_test.cpp
+++ b/src/mongo/db/update/addtoset_node_test.cpp
@@ -42,7 +42,6 @@ namespace mongo {
namespace {
using AddToSetNodeTest = UpdateNodeTest;
-using mongo::mutablebson::Document;
using mongo::mutablebson::Element;
using mongo::mutablebson::countChildren;
@@ -109,7 +108,7 @@ TEST_F(AddToSetNodeTest, ApplyFailsOnNonArray) {
AddToSetNode node;
ASSERT_OK(node.init(update["$addToSet"]["a"], collator));
- Document doc(fromjson("{a: 2}"));
+ mutablebson::Document doc(fromjson("{a: 2}"));
setPathTaken("a");
ASSERT_THROWS_CODE_AND_WHAT(
node.apply(getApplyParams(doc.root()["a"])),
@@ -124,7 +123,7 @@ TEST_F(AddToSetNodeTest, ApplyNonEach) {
AddToSetNode node;
ASSERT_OK(node.init(update["$addToSet"]["a"], collator));
- Document doc(fromjson("{a: [0]}"));
+ mutablebson::Document doc(fromjson("{a: [0]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -141,7 +140,7 @@ TEST_F(AddToSetNodeTest, ApplyNonEachArray) {
AddToSetNode node;
ASSERT_OK(node.init(update["$addToSet"]["a"], collator));
- Document doc(fromjson("{a: [0]}"));
+ mutablebson::Document doc(fromjson("{a: [0]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -158,7 +157,7 @@ TEST_F(AddToSetNodeTest, ApplyEach) {
AddToSetNode node;
ASSERT_OK(node.init(update["$addToSet"]["a"], collator));
- Document doc(fromjson("{a: [0]}"));
+ mutablebson::Document doc(fromjson("{a: [0]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -175,7 +174,7 @@ TEST_F(AddToSetNodeTest, ApplyToEmptyArray) {
AddToSetNode node;
ASSERT_OK(node.init(update["$addToSet"]["a"], collator));
- Document doc(fromjson("{a: []}"));
+ mutablebson::Document doc(fromjson("{a: []}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -192,7 +191,7 @@ TEST_F(AddToSetNodeTest, ApplyDeduplicateElementsToAdd) {
AddToSetNode node;
ASSERT_OK(node.init(update["$addToSet"]["a"], collator));
- Document doc(fromjson("{a: [0]}"));
+ mutablebson::Document doc(fromjson("{a: [0]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -209,7 +208,7 @@ TEST_F(AddToSetNodeTest, ApplyDoNotAddExistingElements) {
AddToSetNode node;
ASSERT_OK(node.init(update["$addToSet"]["a"], collator));
- Document doc(fromjson("{a: [0]}"));
+ mutablebson::Document doc(fromjson("{a: [0]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -226,7 +225,7 @@ TEST_F(AddToSetNodeTest, ApplyDoNotDeduplicateExistingElements) {
AddToSetNode node;
ASSERT_OK(node.init(update["$addToSet"]["a"], collator));
- Document doc(fromjson("{a: [0, 0]}"));
+ mutablebson::Document doc(fromjson("{a: [0, 0]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -243,7 +242,7 @@ TEST_F(AddToSetNodeTest, ApplyNoElementsToAdd) {
AddToSetNode node;
ASSERT_OK(node.init(update["$addToSet"]["a"], collator));
- Document doc(fromjson("{a: [0]}"));
+ mutablebson::Document doc(fromjson("{a: [0]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -260,7 +259,7 @@ TEST_F(AddToSetNodeTest, ApplyNoNonDuplicateElementsToAdd) {
AddToSetNode node;
ASSERT_OK(node.init(update["$addToSet"]["a"], collator));
- Document doc(fromjson("{a: [0]}"));
+ mutablebson::Document doc(fromjson("{a: [0]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -277,7 +276,7 @@ TEST_F(AddToSetNodeTest, ApplyCreateArray) {
AddToSetNode node;
ASSERT_OK(node.init(update["$addToSet"]["a"], collator));
- Document doc(fromjson("{}"));
+ mutablebson::Document doc(fromjson("{}"));
setPathToCreate("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()));
@@ -294,7 +293,7 @@ TEST_F(AddToSetNodeTest, ApplyCreateEmptyArrayIsNotNoop) {
AddToSetNode node;
ASSERT_OK(node.init(update["$addToSet"]["a"], collator));
- Document doc(fromjson("{}"));
+ mutablebson::Document doc(fromjson("{}"));
setPathToCreate("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()));
@@ -311,7 +310,7 @@ TEST_F(AddToSetNodeTest, ApplyDeduplicationOfElementsToAddRespectsCollation) {
AddToSetNode node;
ASSERT_OK(node.init(update["$addToSet"]["a"], &collator));
- Document doc(fromjson("{a: []}"));
+ mutablebson::Document doc(fromjson("{a: []}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -328,7 +327,7 @@ TEST_F(AddToSetNodeTest, ApplyComparisonToExistingElementsRespectsCollation) {
AddToSetNode node;
ASSERT_OK(node.init(update["$addToSet"]["a"], &collator));
- Document doc(fromjson("{a: ['ABC']}"));
+ mutablebson::Document doc(fromjson("{a: ['ABC']}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -349,7 +348,7 @@ TEST_F(AddToSetNodeTest, ApplyRespectsCollationFromSetCollator) {
CollatorInterfaceMock::MockType::kToLowerString);
node.setCollator(&caseInsensitiveCollator);
- Document doc(fromjson("{a: []}"));
+ mutablebson::Document doc(fromjson("{a: []}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -387,7 +386,7 @@ TEST_F(AddToSetNodeTest, ApplyNestedArray) {
AddToSetNode node;
ASSERT_OK(node.init(update["$addToSet"]["a.1"], collator));
- Document doc(fromjson("{ _id : 1, a : [ 1, [ ] ] }"));
+ mutablebson::Document doc(fromjson("{ _id : 1, a : [ 1, [ ] ] }"));
setPathTaken("a.1");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]["1"]));
@@ -404,7 +403,7 @@ TEST_F(AddToSetNodeTest, ApplyIndexesNotAffected) {
AddToSetNode node;
ASSERT_OK(node.init(update["$addToSet"]["a"], collator));
- Document doc(fromjson("{a: [0]}"));
+ mutablebson::Document doc(fromjson("{a: [0]}"));
setPathTaken("a");
addIndexedPath("b");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -420,7 +419,7 @@ TEST_F(AddToSetNodeTest, ApplyNoIndexDataOrLogBuilder) {
AddToSetNode node;
ASSERT_OK(node.init(update["$addToSet"]["a"], collator));
- Document doc(fromjson("{a: [0]}"));
+ mutablebson::Document doc(fromjson("{a: [0]}"));
setPathTaken("a");
setLogBuilderToNull();
auto result = node.apply(getApplyParams(doc.root()["a"]));
diff --git a/src/mongo/db/update/arithmetic_node_test.cpp b/src/mongo/db/update/arithmetic_node_test.cpp
index 76855f66640..3a4d74121ea 100644
--- a/src/mongo/db/update/arithmetic_node_test.cpp
+++ b/src/mongo/db/update/arithmetic_node_test.cpp
@@ -41,7 +41,6 @@ namespace mongo {
namespace {
using ArithmeticNodeTest = UpdateNodeTest;
-using mongo::mutablebson::Document;
using mongo::mutablebson::Element;
using mongo::mutablebson::countChildren;
@@ -116,7 +115,7 @@ TEST_F(ArithmeticNodeTest, ApplyIncNoOp) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a"], collator));
- Document doc(fromjson("{a: 5}"));
+ mutablebson::Document doc(fromjson("{a: 5}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -133,7 +132,7 @@ TEST_F(ArithmeticNodeTest, ApplyMulNoOp) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kMultiply);
ASSERT_OK(node.init(update["$mul"]["a"], collator));
- Document doc(fromjson("{a: 5}"));
+ mutablebson::Document doc(fromjson("{a: 5}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -150,7 +149,7 @@ TEST_F(ArithmeticNodeTest, ApplyRoundingNoOp) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a"], collator));
- Document doc(fromjson("{a: 6.022e23}"));
+ mutablebson::Document doc(fromjson("{a: 6.022e23}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -167,7 +166,7 @@ TEST_F(ArithmeticNodeTest, ApplyEmptyPathToCreate) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a"], collator));
- Document doc(fromjson("{a: 5}"));
+ mutablebson::Document doc(fromjson("{a: 5}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -184,7 +183,7 @@ TEST_F(ArithmeticNodeTest, ApplyCreatePath) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a.b.c"], collator));
- Document doc(fromjson("{a: {d: 5}}"));
+ mutablebson::Document doc(fromjson("{a: {d: 5}}"));
setPathToCreate("b.c");
setPathTaken("a");
addIndexedPath("a");
@@ -202,7 +201,7 @@ TEST_F(ArithmeticNodeTest, ApplyExtendPath) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a.b"], collator));
- Document doc(fromjson("{a: {c: 1}}"));
+ mutablebson::Document doc(fromjson("{a: {c: 1}}"));
setPathToCreate("b");
setPathTaken("a");
addIndexedPath("a.b");
@@ -219,7 +218,7 @@ TEST_F(ArithmeticNodeTest, ApplyCreatePathFromRoot) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a.b"], collator));
- Document doc(fromjson("{c: 5}"));
+ mutablebson::Document doc(fromjson("{c: 5}"));
setPathToCreate("a.b");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()));
@@ -236,7 +235,7 @@ TEST_F(ArithmeticNodeTest, ApplyPositional) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a.$"], collator));
- Document doc(fromjson("{a: [0, 1, 2]}"));
+ mutablebson::Document doc(fromjson("{a: [0, 1, 2]}"));
setPathTaken("a.1");
setMatchedField("1");
addIndexedPath("a");
@@ -254,7 +253,7 @@ TEST_F(ArithmeticNodeTest, ApplyNonViablePathToInc) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a.b"], collator));
- Document doc(fromjson("{a: 5}"));
+ mutablebson::Document doc(fromjson("{a: 5}"));
setPathToCreate("b");
setPathTaken("a");
addIndexedPath("a");
@@ -270,7 +269,7 @@ TEST_F(ArithmeticNodeTest, ApplyNonViablePathToCreateFromReplicationIsNoOp) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a.b"], collator));
- Document doc(fromjson("{a: 5}"));
+ mutablebson::Document doc(fromjson("{a: 5}"));
setPathToCreate("b");
setPathTaken("a");
addIndexedPath("a");
@@ -289,7 +288,7 @@ TEST_F(ArithmeticNodeTest, ApplyNoIndexDataNoLogBuilder) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a"], collator));
- Document doc(fromjson("{a: 5}"));
+ mutablebson::Document doc(fromjson("{a: 5}"));
setPathTaken("a");
setLogBuilderToNull();
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -305,7 +304,7 @@ TEST_F(ArithmeticNodeTest, ApplyDoesNotAffectIndexes) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a"], collator));
- Document doc(fromjson("{a: 5}"));
+ mutablebson::Document doc(fromjson("{a: 5}"));
setPathTaken("a");
addIndexedPath("b");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -321,7 +320,7 @@ TEST_F(ArithmeticNodeTest, IncTypePromotionIsNotANoOp) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a"], collator));
- Document doc(fromjson("{a: NumberInt(2)}"));
+ mutablebson::Document doc(fromjson("{a: NumberInt(2)}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -337,7 +336,7 @@ TEST_F(ArithmeticNodeTest, MulTypePromotionIsNotANoOp) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kMultiply);
ASSERT_OK(node.init(update["$mul"]["a"], collator));
- Document doc(fromjson("{a: NumberInt(2)}"));
+ mutablebson::Document doc(fromjson("{a: NumberInt(2)}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -353,7 +352,7 @@ TEST_F(ArithmeticNodeTest, TypePromotionFromIntToDecimalIsNotANoOp) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a"], collator));
- Document doc(fromjson("{a: NumberInt(5)}"));
+ mutablebson::Document doc(fromjson("{a: NumberInt(5)}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -370,7 +369,7 @@ TEST_F(ArithmeticNodeTest, TypePromotionFromLongToDecimalIsNotANoOp) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a"], collator));
- Document doc(fromjson("{a: NumberLong(5)}"));
+ mutablebson::Document doc(fromjson("{a: NumberLong(5)}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -387,7 +386,7 @@ TEST_F(ArithmeticNodeTest, TypePromotionFromDoubleToDecimalIsNotANoOp) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a"], collator));
- Document doc(fromjson("{a: 5.25}"));
+ mutablebson::Document doc(fromjson("{a: 5.25}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -404,7 +403,7 @@ TEST_F(ArithmeticNodeTest, ApplyPromoteToFloatingPoint) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a"], collator));
- Document doc(fromjson("{a: NumberLong(1)}"));
+ mutablebson::Document doc(fromjson("{a: NumberLong(1)}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -420,7 +419,7 @@ TEST_F(ArithmeticNodeTest, IncrementedDecimalStaysDecimal) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a"], collator));
- Document doc(fromjson("{a: NumberDecimal(\"6.25\")}"));
+ mutablebson::Document doc(fromjson("{a: NumberDecimal(\"6.25\")}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -438,7 +437,7 @@ TEST_F(ArithmeticNodeTest, OverflowIntToLong) {
ASSERT_OK(node.init(update["$inc"]["a"], collator));
const int initialValue = std::numeric_limits<int>::max();
- Document doc(BSON("a" << initialValue));
+ mutablebson::Document doc(BSON("a" << initialValue));
ASSERT_EQUALS(mongo::NumberInt, doc.root()["a"].getType());
setPathTaken("a");
addIndexedPath("a");
@@ -457,7 +456,7 @@ TEST_F(ArithmeticNodeTest, UnderflowIntToLong) {
ASSERT_OK(node.init(update["$inc"]["a"], collator));
const int initialValue = std::numeric_limits<int>::min();
- Document doc(BSON("a" << initialValue));
+ mutablebson::Document doc(BSON("a" << initialValue));
ASSERT_EQUALS(mongo::NumberInt, doc.root()["a"].getType());
setPathTaken("a");
addIndexedPath("a");
@@ -475,8 +474,8 @@ TEST_F(ArithmeticNodeTest, IncModeCanBeReused) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a"], collator));
- Document doc1(fromjson("{a: 1}"));
- Document doc2(fromjson("{a: 2}"));
+ mutablebson::Document doc1(fromjson("{a: 1}"));
+ mutablebson::Document doc2(fromjson("{a: 2}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc1.root()["a"]));
@@ -501,7 +500,7 @@ TEST_F(ArithmeticNodeTest, CreatedNumberHasSameTypeAsInc) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a"], collator));
- Document doc(fromjson("{b: 6}"));
+ mutablebson::Document doc(fromjson("{b: 6}"));
setPathToCreate("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()));
@@ -517,7 +516,7 @@ TEST_F(ArithmeticNodeTest, CreatedNumberHasSameTypeAsMul) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kMultiply);
ASSERT_OK(node.init(update["$mul"]["a"], collator));
- Document doc(fromjson("{b: 6}"));
+ mutablebson::Document doc(fromjson("{b: 6}"));
setPathToCreate("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()));
@@ -533,7 +532,7 @@ TEST_F(ArithmeticNodeTest, ApplyEmptyDocument) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a"], collator));
- Document doc(fromjson("{}"));
+ mutablebson::Document doc(fromjson("{}"));
setPathToCreate("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()));
@@ -549,7 +548,7 @@ TEST_F(ArithmeticNodeTest, ApplyIncToObjectFails) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a"], collator));
- Document doc(fromjson("{_id: 'test_object', a: {b: 1}}"));
+ mutablebson::Document doc(fromjson("{_id: 'test_object', a: {b: 1}}"));
setPathTaken("a");
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root()["a"])),
@@ -565,7 +564,7 @@ TEST_F(ArithmeticNodeTest, ApplyIncToArrayFails) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a"], collator));
- Document doc(fromjson("{_id: 'test_object', a: []}"));
+ mutablebson::Document doc(fromjson("{_id: 'test_object', a: []}"));
setPathTaken("a");
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root()["a"])),
@@ -581,7 +580,7 @@ TEST_F(ArithmeticNodeTest, ApplyIncToStringFails) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a"], collator));
- Document doc(fromjson("{_id: 'test_object', a: \"foo\"}"));
+ mutablebson::Document doc(fromjson("{_id: 'test_object', a: \"foo\"}"));
setPathTaken("a");
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root()["a"])),
@@ -597,7 +596,7 @@ TEST_F(ArithmeticNodeTest, ApplyNewPath) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a"], collator));
- Document doc(fromjson("{b: 1}"));
+ mutablebson::Document doc(fromjson("{b: 1}"));
setPathToCreate("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()));
@@ -613,7 +612,7 @@ TEST_F(ArithmeticNodeTest, ApplyEmptyIndexData) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a"], collator));
- Document doc(fromjson("{a: 1}"));
+ mutablebson::Document doc(fromjson("{a: 1}"));
setPathTaken("a");
node.apply(getApplyParams(doc.root()["a"]));
ASSERT_EQUALS(fromjson("{a: 3}"), doc);
@@ -628,7 +627,7 @@ TEST_F(ArithmeticNodeTest, ApplyNoOpDottedPath) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a.b"], collator));
- Document doc(fromjson("{a: {b: 2}}"));
+ mutablebson::Document doc(fromjson("{a: {b: 2}}"));
setPathTaken("a.b");
addIndexedPath("a.b");
auto result = node.apply(getApplyParams(doc.root()["a"]["b"]));
@@ -644,7 +643,7 @@ TEST_F(ArithmeticNodeTest, TypePromotionOnDottedPathIsNotANoOp) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a.b"], collator));
- Document doc(fromjson("{a: {b: NumberInt(2)}}"));
+ mutablebson::Document doc(fromjson("{a: {b: NumberInt(2)}}"));
setPathTaken("a.b");
addIndexedPath("a.b");
auto result = node.apply(getApplyParams(doc.root()["a"]["b"]));
@@ -660,7 +659,7 @@ TEST_F(ArithmeticNodeTest, ApplyPathNotViableArray) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a.b"], collator));
- Document doc(fromjson("{a:[{b:1}]}"));
+ mutablebson::Document doc(fromjson("{a:[{b:1}]}"));
setPathToCreate("b");
setPathTaken("a");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root()["a"])),
@@ -675,7 +674,7 @@ TEST_F(ArithmeticNodeTest, ApplyInPlaceDottedPath) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a.b"], collator));
- Document doc(fromjson("{a: {b: 1}}"));
+ mutablebson::Document doc(fromjson("{a: {b: 1}}"));
setPathTaken("a.b");
addIndexedPath("a.b");
auto result = node.apply(getApplyParams(doc.root()["a"]["b"]));
@@ -691,7 +690,7 @@ TEST_F(ArithmeticNodeTest, ApplyPromotionDottedPath) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a.b"], collator));
- Document doc(fromjson("{a: {b: NumberInt(3)}}"));
+ mutablebson::Document doc(fromjson("{a: {b: NumberInt(3)}}"));
setPathTaken("a.b");
addIndexedPath("a.b");
auto result = node.apply(getApplyParams(doc.root()["a"]["b"]));
@@ -707,7 +706,7 @@ TEST_F(ArithmeticNodeTest, ApplyDottedPathEmptyDoc) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a.b"], collator));
- Document doc(fromjson("{}"));
+ mutablebson::Document doc(fromjson("{}"));
setPathToCreate("a.b");
addIndexedPath("a.b");
auto result = node.apply(getApplyParams(doc.root()));
@@ -723,7 +722,7 @@ TEST_F(ArithmeticNodeTest, ApplyFieldWithDot) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a.b"], collator));
- Document doc(fromjson("{'a.b':4}"));
+ mutablebson::Document doc(fromjson("{'a.b':4}"));
setPathToCreate("a.b");
addIndexedPath("a.b");
auto result = node.apply(getApplyParams(doc.root()));
@@ -739,7 +738,7 @@ TEST_F(ArithmeticNodeTest, ApplyNoOpArrayIndex) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a.2.b"], collator));
- Document doc(fromjson("{a: [{b: 0},{b: 1},{b: 2}]}"));
+ mutablebson::Document doc(fromjson("{a: [{b: 0},{b: 1},{b: 2}]}"));
setPathTaken("a.2.b");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]["2"]["b"]));
@@ -755,7 +754,8 @@ TEST_F(ArithmeticNodeTest, TypePromotionInArrayIsNotANoOp) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$set"]["a.2.b"], collator));
- Document doc(fromjson("{a: [{b: NumberInt(0)},{b: NumberInt(1)},{b: NumberInt(2)}]}"));
+ mutablebson::Document doc(
+ fromjson("{a: [{b: NumberInt(0)},{b: NumberInt(1)},{b: NumberInt(2)}]}"));
setPathTaken("a.2.b");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]["2"]["b"]));
@@ -771,7 +771,7 @@ TEST_F(ArithmeticNodeTest, ApplyNonViablePathThroughArray) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a.2.b"], collator));
- Document doc(fromjson("{a: 0}"));
+ mutablebson::Document doc(fromjson("{a: 0}"));
setPathToCreate("2.b");
setPathTaken("a");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root()["a"])),
@@ -786,7 +786,7 @@ TEST_F(ArithmeticNodeTest, ApplyInPlaceArrayIndex) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a.2.b"], collator));
- Document doc(fromjson("{a: [{b: 0},{b: 1},{b: 1}]}"));
+ mutablebson::Document doc(fromjson("{a: [{b: 0},{b: 1},{b: 1}]}"));
setPathTaken("a.2.b");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]["2"]["b"]));
@@ -802,7 +802,7 @@ TEST_F(ArithmeticNodeTest, ApplyAppendArray) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a.2.b"], collator));
- Document doc(fromjson("{a: [{b: 0},{b: 1}]}"));
+ mutablebson::Document doc(fromjson("{a: [{b: 0},{b: 1}]}"));
setPathToCreate("2.b");
setPathTaken("a");
addIndexedPath("a");
@@ -819,7 +819,7 @@ TEST_F(ArithmeticNodeTest, ApplyPaddingArray) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a.2.b"], collator));
- Document doc(fromjson("{a: [{b: 0}]}"));
+ mutablebson::Document doc(fromjson("{a: [{b: 0}]}"));
setPathToCreate("2.b");
setPathTaken("a");
addIndexedPath("a");
@@ -836,7 +836,7 @@ TEST_F(ArithmeticNodeTest, ApplyNumericObject) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a.2.b"], collator));
- Document doc(fromjson("{a: {b: 0}}"));
+ mutablebson::Document doc(fromjson("{a: {b: 0}}"));
setPathToCreate("2.b");
setPathTaken("a");
addIndexedPath("a");
@@ -853,7 +853,7 @@ TEST_F(ArithmeticNodeTest, ApplyNumericField) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a.2.b"], collator));
- Document doc(fromjson("{a: {'2': {b: 1}}}"));
+ mutablebson::Document doc(fromjson("{a: {'2': {b: 1}}}"));
setPathTaken("a.2.b");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]["2"]["b"]));
@@ -869,7 +869,7 @@ TEST_F(ArithmeticNodeTest, ApplyExtendNumericField) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a.2.b"], collator));
- Document doc(fromjson("{a: {'2': {c: 1}}}"));
+ mutablebson::Document doc(fromjson("{a: {'2': {c: 1}}}"));
setPathToCreate("b");
setPathTaken("a.2");
addIndexedPath("a");
@@ -886,7 +886,7 @@ TEST_F(ArithmeticNodeTest, ApplyNumericFieldToEmptyObject) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$set"]["a.2.b"], collator));
- Document doc(fromjson("{a: {}}"));
+ mutablebson::Document doc(fromjson("{a: {}}"));
setPathToCreate("2.b");
setPathTaken("a");
addIndexedPath("a");
@@ -903,7 +903,7 @@ TEST_F(ArithmeticNodeTest, ApplyEmptyArray) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$set"]["a.2.b"], collator));
- Document doc(fromjson("{a: []}"));
+ mutablebson::Document doc(fromjson("{a: []}"));
setPathToCreate("2.b");
setPathTaken("a");
addIndexedPath("a");
@@ -920,7 +920,7 @@ TEST_F(ArithmeticNodeTest, ApplyLogDottedPath) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a.2.b"], collator));
- Document doc(fromjson("{a: [{b:0}, {b:1}]}"));
+ mutablebson::Document doc(fromjson("{a: [{b:0}, {b:1}]}"));
setPathToCreate("2.b");
setPathTaken("a");
node.apply(getApplyParams(doc.root()["a"]));
@@ -936,7 +936,7 @@ TEST_F(ArithmeticNodeTest, LogEmptyArray) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a.2.b"], collator));
- Document doc(fromjson("{a: []}"));
+ mutablebson::Document doc(fromjson("{a: []}"));
setPathToCreate("2.b");
setPathTaken("a");
node.apply(getApplyParams(doc.root()["a"]));
@@ -952,7 +952,7 @@ TEST_F(ArithmeticNodeTest, LogEmptyObject) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kAdd);
ASSERT_OK(node.init(update["$inc"]["a.2.b"], collator));
- Document doc(fromjson("{a: {}}"));
+ mutablebson::Document doc(fromjson("{a: {}}"));
setPathToCreate("2.b");
setPathTaken("a");
node.apply(getApplyParams(doc.root()["a"]));
@@ -968,7 +968,7 @@ TEST_F(ArithmeticNodeTest, ApplyDeserializedDocNotNoOp) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kMultiply);
ASSERT_OK(node.init(update["$mul"]["b"], collator));
- Document doc(fromjson("{a: 1}"));
+ mutablebson::Document doc(fromjson("{a: 1}"));
// De-serialize the int.
doc.root()["a"].setValueInt(1).transitional_ignore();
@@ -987,7 +987,7 @@ TEST_F(ArithmeticNodeTest, ApplyToDeserializedDocNoOp) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kMultiply);
ASSERT_OK(node.init(update["$mul"]["a"], collator));
- Document doc(fromjson("{a: 1}"));
+ mutablebson::Document doc(fromjson("{a: 1}"));
// De-serialize the int.
doc.root()["a"].setValueInt(2).transitional_ignore();
@@ -1006,7 +1006,7 @@ TEST_F(ArithmeticNodeTest, ApplyToDeserializedDocNestedNoop) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kMultiply);
ASSERT_OK(node.init(update["$mul"]["a.b"], collator));
- Document doc{BSONObj()};
+ mutablebson::Document doc{BSONObj()};
// De-serialize the int.
doc.root().appendObject("a", BSON("b" << static_cast<int>(1))).transitional_ignore();
@@ -1025,7 +1025,7 @@ TEST_F(ArithmeticNodeTest, ApplyToDeserializedDocNestedNotNoop) {
ArithmeticNode node(ArithmeticNode::ArithmeticOp::kMultiply);
ASSERT_OK(node.init(update["$mul"]["a.b"], collator));
- Document doc{BSONObj()};
+ mutablebson::Document doc{BSONObj()};
// De-serialize the int.
doc.root().appendObject("a", BSON("b" << static_cast<int>(1))).transitional_ignore();
diff --git a/src/mongo/db/update/bit_node_test.cpp b/src/mongo/db/update/bit_node_test.cpp
index 54db7ccdafb..868d064f66b 100644
--- a/src/mongo/db/update/bit_node_test.cpp
+++ b/src/mongo/db/update/bit_node_test.cpp
@@ -41,7 +41,6 @@ namespace mongo {
namespace {
using BitNodeTest = UpdateNodeTest;
-using mongo::mutablebson::Document;
using mongo::mutablebson::Element;
using mongo::mutablebson::countChildren;
@@ -156,7 +155,7 @@ TEST_F(BitNodeTest, ApplyAndLogEmptyDocumentAnd) {
BitNode node;
ASSERT_OK(node.init(update["$bit"]["a"], collator));
- Document doc(fromjson("{}"));
+ mutablebson::Document doc(fromjson("{}"));
setPathToCreate("a");
auto result = node.apply(getApplyParams(doc.root()));
ASSERT_FALSE(result.noop);
@@ -171,7 +170,7 @@ TEST_F(BitNodeTest, ApplyAndLogEmptyDocumentOr) {
BitNode node;
ASSERT_OK(node.init(update["$bit"]["a"], collator));
- Document doc(fromjson("{}"));
+ mutablebson::Document doc(fromjson("{}"));
setPathToCreate("a");
auto result = node.apply(getApplyParams(doc.root()));
ASSERT_FALSE(result.noop);
@@ -186,7 +185,7 @@ TEST_F(BitNodeTest, ApplyAndLogEmptyDocumentXor) {
BitNode node;
ASSERT_OK(node.init(update["$bit"]["a"], collator));
- Document doc(fromjson("{}"));
+ mutablebson::Document doc(fromjson("{}"));
setPathToCreate("a");
auto result = node.apply(getApplyParams(doc.root()));
ASSERT_FALSE(result.noop);
@@ -201,7 +200,7 @@ TEST_F(BitNodeTest, ApplyAndLogSimpleDocumentAnd) {
BitNode node;
ASSERT_OK(node.init(update["$bit"]["a"], collator));
- Document doc(BSON("a" << 0b0101));
+ mutablebson::Document doc(BSON("a" << 0b0101));
setPathTaken("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
ASSERT_FALSE(result.noop);
@@ -216,7 +215,7 @@ TEST_F(BitNodeTest, ApplyAndLogSimpleDocumentOr) {
BitNode node;
ASSERT_OK(node.init(update["$bit"]["a"], collator));
- Document doc(BSON("a" << 0b0101));
+ mutablebson::Document doc(BSON("a" << 0b0101));
setPathTaken("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
ASSERT_FALSE(result.noop);
@@ -231,7 +230,7 @@ TEST_F(BitNodeTest, ApplyAndLogSimpleDocumentXor) {
BitNode node;
ASSERT_OK(node.init(update["$bit"]["a"], collator));
- Document doc(BSON("a" << 0b0101));
+ mutablebson::Document doc(BSON("a" << 0b0101));
setPathTaken("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
ASSERT_FALSE(result.noop);
@@ -246,7 +245,7 @@ TEST_F(BitNodeTest, ApplyShouldReportNoOp) {
BitNode node;
ASSERT_OK(node.init(update["$bit"]["a"], collator));
- Document doc(BSON("a" << 1));
+ mutablebson::Document doc(BSON("a" << 1));
setPathTaken("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
ASSERT_TRUE(result.noop);
@@ -266,7 +265,7 @@ TEST_F(BitNodeTest, ApplyMultipleBitOps) {
BitNode node;
ASSERT_OK(node.init(update["$bit"]["a"], collator));
- Document doc(BSON("a" << 0b1111111100000000));
+ mutablebson::Document doc(BSON("a" << 0b1111111100000000));
setPathTaken("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
ASSERT_FALSE(result.noop);
@@ -281,7 +280,7 @@ TEST_F(BitNodeTest, ApplyRepeatedBitOps) {
BitNode node;
ASSERT_OK(node.init(update["$bit"]["a"], collator));
- Document doc(BSON("a" << 0b11110000));
+ mutablebson::Document doc(BSON("a" << 0b11110000));
setPathTaken("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
ASSERT_FALSE(result.noop);
diff --git a/src/mongo/db/update/compare_node_test.cpp b/src/mongo/db/update/compare_node_test.cpp
index d69ac1c5d8b..37949aef2dc 100644
--- a/src/mongo/db/update/compare_node_test.cpp
+++ b/src/mongo/db/update/compare_node_test.cpp
@@ -42,7 +42,6 @@ namespace mongo {
namespace {
using CompareNodeTest = UpdateNodeTest;
-using mongo::mutablebson::Document;
using mongo::mutablebson::Element;
using mongo::mutablebson::countChildren;
@@ -59,7 +58,7 @@ TEST_F(CompareNodeTest, ApplyMaxSameNumber) {
CompareNode node(CompareNode::CompareMode::kMax);
ASSERT_OK(node.init(update["$max"]["a"], collator));
- Document doc(fromjson("{a: 1}"));
+ mutablebson::Document doc(fromjson("{a: 1}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -76,7 +75,7 @@ TEST_F(CompareNodeTest, ApplyMinSameNumber) {
CompareNode node(CompareNode::CompareMode::kMin);
ASSERT_OK(node.init(update["$min"]["a"], collator));
- Document doc(fromjson("{a: 1}"));
+ mutablebson::Document doc(fromjson("{a: 1}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -93,7 +92,7 @@ TEST_F(CompareNodeTest, ApplyMaxNumberIsLess) {
CompareNode node(CompareNode::CompareMode::kMax);
ASSERT_OK(node.init(update["$max"]["a"], collator));
- Document doc(fromjson("{a: 1}"));
+ mutablebson::Document doc(fromjson("{a: 1}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -110,7 +109,7 @@ TEST_F(CompareNodeTest, ApplyMinNumberIsMore) {
CompareNode node(CompareNode::CompareMode::kMin);
ASSERT_OK(node.init(update["$min"]["a"], collator));
- Document doc(fromjson("{a: 1}"));
+ mutablebson::Document doc(fromjson("{a: 1}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -127,7 +126,7 @@ TEST_F(CompareNodeTest, ApplyMaxSameValInt) {
CompareNode node(CompareNode::CompareMode::kMax);
ASSERT_OK(node.init(update["$max"]["a"], collator));
- Document doc(fromjson("{a: 1.0}"));
+ mutablebson::Document doc(fromjson("{a: 1.0}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -144,7 +143,7 @@ TEST_F(CompareNodeTest, ApplyMaxSameValIntZero) {
CompareNode node(CompareNode::CompareMode::kMax);
ASSERT_OK(node.init(update["$max"]["a"], collator));
- Document doc(fromjson("{a: 0.0}"));
+ mutablebson::Document doc(fromjson("{a: 0.0}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -161,7 +160,7 @@ TEST_F(CompareNodeTest, ApplyMinSameValIntZero) {
CompareNode node(CompareNode::CompareMode::kMin);
ASSERT_OK(node.init(update["$min"]["a"], collator));
- Document doc(fromjson("{a: 0.0}"));
+ mutablebson::Document doc(fromjson("{a: 0.0}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -178,7 +177,7 @@ TEST_F(CompareNodeTest, ApplyMissingFieldMinNumber) {
CompareNode node(CompareNode::CompareMode::kMin);
ASSERT_OK(node.init(update["$min"]["a"], collator));
- Document doc(fromjson("{}"));
+ mutablebson::Document doc(fromjson("{}"));
setPathToCreate("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()));
@@ -195,7 +194,7 @@ TEST_F(CompareNodeTest, ApplyExistingNumberMinNumber) {
CompareNode node(CompareNode::CompareMode::kMin);
ASSERT_OK(node.init(update["$min"]["a"], collator));
- Document doc(fromjson("{a: 1}"));
+ mutablebson::Document doc(fromjson("{a: 1}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -212,7 +211,7 @@ TEST_F(CompareNodeTest, ApplyMissingFieldMaxNumber) {
CompareNode node(CompareNode::CompareMode::kMax);
ASSERT_OK(node.init(update["$max"]["a"], collator));
- Document doc(fromjson("{}"));
+ mutablebson::Document doc(fromjson("{}"));
setPathToCreate("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()));
@@ -229,7 +228,7 @@ TEST_F(CompareNodeTest, ApplyExistingNumberMaxNumber) {
CompareNode node(CompareNode::CompareMode::kMax);
ASSERT_OK(node.init(update["$max"]["a"], collator));
- Document doc(fromjson("{a: 1}"));
+ mutablebson::Document doc(fromjson("{a: 1}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -246,7 +245,7 @@ TEST_F(CompareNodeTest, ApplyExistingDateMaxDate) {
CompareNode node(CompareNode::CompareMode::kMax);
ASSERT_OK(node.init(update["$max"]["a"], collator));
- Document doc(fromjson("{a: {$date: 0}}"));
+ mutablebson::Document doc(fromjson("{a: {$date: 0}}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -263,7 +262,7 @@ TEST_F(CompareNodeTest, ApplyExistingEmbeddedDocMaxDoc) {
CompareNode node(CompareNode::CompareMode::kMax);
ASSERT_OK(node.init(update["$max"]["a"], collator));
- Document doc(fromjson("{a: {b: 2}}"));
+ mutablebson::Document doc(fromjson("{a: {b: 2}}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -280,7 +279,7 @@ TEST_F(CompareNodeTest, ApplyExistingEmbeddedDocMaxNumber) {
CompareNode node(CompareNode::CompareMode::kMax);
ASSERT_OK(node.init(update["$max"]["a"], collator));
- Document doc(fromjson("{a: {b: 2}}"));
+ mutablebson::Document doc(fromjson("{a: {b: 2}}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -297,7 +296,7 @@ TEST_F(CompareNodeTest, ApplyMinRespectsCollation) {
CompareNode node(CompareNode::CompareMode::kMin);
ASSERT_OK(node.init(update["$min"]["a"], &collator));
- Document doc(fromjson("{a: 'cbc'}"));
+ mutablebson::Document doc(fromjson("{a: 'cbc'}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -318,7 +317,7 @@ TEST_F(CompareNodeTest, ApplyMinRespectsCollationFromSetCollator) {
CollatorInterfaceMock::MockType::kReverseString);
node.setCollator(&reverseStringCollator);
- Document doc(fromjson("{a: 'cbc'}"));
+ mutablebson::Document doc(fromjson("{a: 'cbc'}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -339,7 +338,7 @@ TEST_F(CompareNodeTest, ApplyMaxRespectsCollationFromSetCollator) {
CollatorInterfaceMock::MockType::kReverseString);
node.setCollator(&reverseStringCollator);
- Document doc(fromjson("{a: 'cbc'}"));
+ mutablebson::Document doc(fromjson("{a: 'cbc'}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -377,7 +376,7 @@ TEST_F(CompareNodeTest, ApplyIndexesNotAffected) {
CompareNode node(CompareNode::CompareMode::kMax);
ASSERT_OK(node.init(update["$max"]["a"], collator));
- Document doc(fromjson("{a: 0}"));
+ mutablebson::Document doc(fromjson("{a: 0}"));
setPathTaken("a");
addIndexedPath("b");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -394,7 +393,7 @@ TEST_F(CompareNodeTest, ApplyNoIndexDataOrLogBuilder) {
CompareNode node(CompareNode::CompareMode::kMax);
ASSERT_OK(node.init(update["$max"]["a"], collator));
- Document doc(fromjson("{a: 0}"));
+ mutablebson::Document doc(fromjson("{a: 0}"));
setPathTaken("a");
setLogBuilderToNull();
auto result = node.apply(getApplyParams(doc.root()["a"]));
diff --git a/src/mongo/db/update/current_date_node_test.cpp b/src/mongo/db/update/current_date_node_test.cpp
index 7a5005b83d8..689ada219f6 100644
--- a/src/mongo/db/update/current_date_node_test.cpp
+++ b/src/mongo/db/update/current_date_node_test.cpp
@@ -41,7 +41,6 @@ namespace mongo {
namespace {
using CurrentDateNodeTest = UpdateNodeTest;
-using mongo::mutablebson::Document;
using mongo::mutablebson::Element;
using mongo::mutablebson::countChildren;
@@ -128,7 +127,7 @@ TEST_F(CurrentDateNodeTest, ApplyTrue) {
CurrentDateNode node;
ASSERT_OK(node.init(update["$currentDate"]["a"], collator));
- Document doc(fromjson("{a: 0}"));
+ mutablebson::Document doc(fromjson("{a: 0}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -152,7 +151,7 @@ TEST_F(CurrentDateNodeTest, ApplyFalse) {
CurrentDateNode node;
ASSERT_OK(node.init(update["$currentDate"]["a"], collator));
- Document doc(fromjson("{a: 0}"));
+ mutablebson::Document doc(fromjson("{a: 0}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -176,7 +175,7 @@ TEST_F(CurrentDateNodeTest, ApplyDate) {
CurrentDateNode node;
ASSERT_OK(node.init(update["$currentDate"]["a"], collator));
- Document doc(fromjson("{a: 0}"));
+ mutablebson::Document doc(fromjson("{a: 0}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -200,7 +199,7 @@ TEST_F(CurrentDateNodeTest, ApplyTimestamp) {
CurrentDateNode node;
ASSERT_OK(node.init(update["$currentDate"]["a"], collator));
- Document doc(fromjson("{a: 0}"));
+ mutablebson::Document doc(fromjson("{a: 0}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -224,7 +223,7 @@ TEST_F(CurrentDateNodeTest, ApplyFieldDoesNotExist) {
CurrentDateNode node;
ASSERT_OK(node.init(update["$currentDate"]["a"], collator));
- Document doc(fromjson("{}"));
+ mutablebson::Document doc(fromjson("{}"));
setPathToCreate("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()));
@@ -248,7 +247,7 @@ TEST_F(CurrentDateNodeTest, ApplyIndexesNotAffected) {
CurrentDateNode node;
ASSERT_OK(node.init(update["$currentDate"]["a"], collator));
- Document doc(fromjson("{a: 0}"));
+ mutablebson::Document doc(fromjson("{a: 0}"));
setPathTaken("a");
addIndexedPath("b");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -272,7 +271,7 @@ TEST_F(CurrentDateNodeTest, ApplyNoIndexDataOrLogBuilder) {
CurrentDateNode node;
ASSERT_OK(node.init(update["$currentDate"]["a"], collator));
- Document doc(fromjson("{a: 0}"));
+ mutablebson::Document doc(fromjson("{a: 0}"));
setPathTaken("a");
setLogBuilderToNull();
auto result = node.apply(getApplyParams(doc.root()["a"]));
diff --git a/src/mongo/db/update/log_builder.cpp b/src/mongo/db/update/log_builder.cpp
index deddbab3840..173c8afb3f9 100644
--- a/src/mongo/db/update/log_builder.cpp
+++ b/src/mongo/db/update/log_builder.cpp
@@ -31,7 +31,6 @@
namespace mongo {
-using mutablebson::Document;
using mutablebson::Element;
namespace str = mongoutils::str;
@@ -49,7 +48,7 @@ inline Status LogBuilder::addToSection(Element newElt, Element* section, const c
"LogBuilder: Invalid attempt to add a $set/$unset entry"
"to a log with an existing object replacement");
- Document& doc = _logRoot.getDocument();
+ mutablebson::Document& doc = _logRoot.getDocument();
// We should not already have an element with the section name under the root.
dassert(_logRoot[sectionName] == doc.end());
diff --git a/src/mongo/db/update/object_replace_node_test.cpp b/src/mongo/db/update/object_replace_node_test.cpp
index 69c3bbf6070..645a3e69ff3 100644
--- a/src/mongo/db/update/object_replace_node_test.cpp
+++ b/src/mongo/db/update/object_replace_node_test.cpp
@@ -42,7 +42,6 @@ namespace mongo {
namespace {
using ObjectReplaceNodeTest = UpdateNodeTest;
-using mongo::mutablebson::Document;
using mongo::mutablebson::Element;
using mongo::mutablebson::countChildren;
@@ -50,7 +49,7 @@ TEST_F(ObjectReplaceNodeTest, Noop) {
auto obj = fromjson("{a: 1, b: 2}");
ObjectReplaceNode node(obj);
- Document doc(fromjson("{a: 1, b: 2}"));
+ mutablebson::Document doc(fromjson("{a: 1, b: 2}"));
auto result = node.apply(getApplyParams(doc.root()));
ASSERT_TRUE(result.noop);
ASSERT_FALSE(result.indexesAffected);
@@ -63,7 +62,7 @@ TEST_F(ObjectReplaceNodeTest, ShouldNotCreateIdIfNoIdExistsAndNoneIsSpecified) {
auto obj = fromjson("{a: 1, b: 2}");
ObjectReplaceNode node(obj);
- Document doc(fromjson("{c: 1, d: 2}"));
+ mutablebson::Document doc(fromjson("{c: 1, d: 2}"));
auto result = node.apply(getApplyParams(doc.root()));
ASSERT_FALSE(result.noop);
ASSERT_TRUE(result.indexesAffected);
@@ -76,7 +75,7 @@ TEST_F(ObjectReplaceNodeTest, ShouldPreserveIdOfExistingDocumentIfIdNotSpecified
auto obj = fromjson("{a: 1, b: 2}");
ObjectReplaceNode node(obj);
- Document doc(fromjson("{_id: 0, c: 1, d: 2}"));
+ mutablebson::Document doc(fromjson("{_id: 0, c: 1, d: 2}"));
auto result = node.apply(getApplyParams(doc.root()));
ASSERT_FALSE(result.noop);
ASSERT_TRUE(result.indexesAffected);
@@ -89,7 +88,7 @@ TEST_F(ObjectReplaceNodeTest, ShouldSucceedWhenImmutableIdIsNotModified) {
auto obj = fromjson("{_id: 0, a: 1, b: 2}");
ObjectReplaceNode node(obj);
- Document doc(fromjson("{_id: 0, c: 1, d: 2}"));
+ mutablebson::Document doc(fromjson("{_id: 0, c: 1, d: 2}"));
addImmutablePath("_id");
auto result = node.apply(getApplyParams(doc.root()));
ASSERT_FALSE(result.noop);
@@ -103,7 +102,7 @@ TEST_F(ObjectReplaceNodeTest, IdTimestampNotModified) {
auto obj = fromjson("{_id: Timestamp(0,0)}");
ObjectReplaceNode node(obj);
- Document doc(fromjson("{}"));
+ mutablebson::Document doc(fromjson("{}"));
auto result = node.apply(getApplyParams(doc.root()));
ASSERT_FALSE(result.noop);
ASSERT_TRUE(result.indexesAffected);
@@ -116,7 +115,7 @@ TEST_F(ObjectReplaceNodeTest, NonIdTimestampsModified) {
auto obj = fromjson("{a: Timestamp(0,0), b: Timestamp(0,0)}");
ObjectReplaceNode node(obj);
- Document doc(fromjson("{}"));
+ mutablebson::Document doc(fromjson("{}"));
auto result = node.apply(getApplyParams(doc.root()));
ASSERT_FALSE(result.noop);
ASSERT_TRUE(result.indexesAffected);
@@ -143,7 +142,7 @@ TEST_F(ObjectReplaceNodeTest, ComplexDoc) {
auto obj = fromjson("{a: 1, b: [0, 1, 2], c: {d: 1}}");
ObjectReplaceNode node(obj);
- Document doc(fromjson("{a: 1, b: [0, 2, 2], e: []}"));
+ mutablebson::Document doc(fromjson("{a: 1, b: [0, 2, 2], e: []}"));
auto result = node.apply(getApplyParams(doc.root()));
ASSERT_FALSE(result.noop);
ASSERT_TRUE(result.indexesAffected);
@@ -156,7 +155,7 @@ TEST_F(ObjectReplaceNodeTest, CannotRemoveImmutablePath) {
auto obj = fromjson("{_id: 0, c: 1}");
ObjectReplaceNode node(obj);
- Document doc(fromjson("{_id: 0, a: {b: 1}}"));
+ mutablebson::Document doc(fromjson("{_id: 0, a: {b: 1}}"));
addImmutablePath("a.b");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root())),
UserException,
@@ -169,7 +168,7 @@ TEST_F(ObjectReplaceNodeTest, IdFieldIsNotRemoved) {
auto obj = fromjson("{a: 1}");
ObjectReplaceNode node(obj);
- Document doc(fromjson("{_id: 0, b: 1}"));
+ mutablebson::Document doc(fromjson("{_id: 0, b: 1}"));
addImmutablePath("_id");
auto result = node.apply(getApplyParams(doc.root()));
ASSERT_FALSE(result.noop);
@@ -183,7 +182,7 @@ TEST_F(ObjectReplaceNodeTest, CannotReplaceImmutablePathWithArrayField) {
auto obj = fromjson("{_id: 0, a: [{b: 1}]}");
ObjectReplaceNode node(obj);
- Document doc(fromjson("{_id: 0, a: {b: 1}}"));
+ mutablebson::Document doc(fromjson("{_id: 0, a: {b: 1}}"));
addImmutablePath("a.b");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root())),
UserException,
@@ -196,7 +195,7 @@ TEST_F(ObjectReplaceNodeTest, CannotMakeImmutablePathArrayDescendant) {
auto obj = fromjson("{_id: 0, a: [1]}");
ObjectReplaceNode node(obj);
- Document doc(fromjson("{_id: 0, a: {'0': 1}}"));
+ mutablebson::Document doc(fromjson("{_id: 0, a: {'0': 1}}"));
addImmutablePath("a.0");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root())),
UserException,
@@ -209,7 +208,7 @@ TEST_F(ObjectReplaceNodeTest, CannotModifyImmutablePath) {
auto obj = fromjson("{_id: 0, a: {b: 2}}");
ObjectReplaceNode node(obj);
- Document doc(fromjson("{_id: 0, a: {b: 1}}"));
+ mutablebson::Document doc(fromjson("{_id: 0, a: {b: 1}}"));
addImmutablePath("a.b");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root())),
UserException,
@@ -222,7 +221,7 @@ TEST_F(ObjectReplaceNodeTest, CannotModifyImmutableId) {
auto obj = fromjson("{_id: 1}");
ObjectReplaceNode node(obj);
- Document doc(fromjson("{_id: 0}"));
+ mutablebson::Document doc(fromjson("{_id: 0}"));
addImmutablePath("_id");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root())),
UserException,
@@ -235,7 +234,7 @@ TEST_F(ObjectReplaceNodeTest, CanAddImmutableField) {
auto obj = fromjson("{a: {b: 1}}");
ObjectReplaceNode node(obj);
- Document doc(fromjson("{c: 1}"));
+ mutablebson::Document doc(fromjson("{c: 1}"));
addImmutablePath("a.b");
auto result = node.apply(getApplyParams(doc.root()));
ASSERT_FALSE(result.noop);
@@ -249,7 +248,7 @@ TEST_F(ObjectReplaceNodeTest, CanAddImmutableId) {
auto obj = fromjson("{_id: 0}");
ObjectReplaceNode node(obj);
- Document doc(fromjson("{c: 1}"));
+ mutablebson::Document doc(fromjson("{c: 1}"));
addImmutablePath("_id");
auto result = node.apply(getApplyParams(doc.root()));
ASSERT_FALSE(result.noop);
@@ -263,7 +262,7 @@ TEST_F(ObjectReplaceNodeTest, CannotCreateDollarPrefixedNameWhenValidateForStora
auto obj = fromjson("{a: {b: 1, $bad: 1}}");
ObjectReplaceNode node(obj);
- Document doc(fromjson("{}"));
+ mutablebson::Document doc(fromjson("{}"));
ASSERT_THROWS_CODE_AND_WHAT(
node.apply(getApplyParams(doc.root())),
UserException,
@@ -275,7 +274,7 @@ TEST_F(ObjectReplaceNodeTest, CanCreateDollarPrefixedNameWhenValidateForStorageI
auto obj = fromjson("{a: {b: 1, $bad: 1}}");
ObjectReplaceNode node(obj);
- Document doc(fromjson("{}"));
+ mutablebson::Document doc(fromjson("{}"));
setValidateForStorage(false);
auto result = node.apply(getApplyParams(doc.root()));
ASSERT_FALSE(result.noop);
@@ -289,7 +288,7 @@ TEST_F(ObjectReplaceNodeTest, NoLogBuilder) {
auto obj = fromjson("{a: 1}");
ObjectReplaceNode node(obj);
- Document doc(fromjson("{b: 1}"));
+ mutablebson::Document doc(fromjson("{b: 1}"));
setLogBuilderToNull();
auto result = node.apply(getApplyParams(doc.root()));
ASSERT_FALSE(result.noop);
diff --git a/src/mongo/db/update/path_support_test.cpp b/src/mongo/db/update/path_support_test.cpp
index 4a915bdf7d5..339781699e1 100644
--- a/src/mongo/db/update/path_support_test.cpp
+++ b/src/mongo/db/update/path_support_test.cpp
@@ -56,9 +56,9 @@
namespace {
using namespace mongo;
-using namespace mutablebson;
using namespace pathsupport;
using mongoutils::str::stream;
+using mutablebson::Element;
using std::unique_ptr;
using std::string;
@@ -66,7 +66,7 @@ class EmptyDoc : public mongo::unittest::Test {
public:
EmptyDoc() : _doc() {}
- Document& doc() {
+ mutablebson::Document& doc() {
return _doc;
}
@@ -83,7 +83,7 @@ public:
}
private:
- Document _doc;
+ mutablebson::Document _doc;
FieldRef _field;
};
@@ -137,7 +137,7 @@ public:
ASSERT_OK(root().appendInt("a", 1));
}
- Document& doc() {
+ mutablebson::Document& doc() {
return _doc;
}
@@ -153,7 +153,7 @@ public:
}
private:
- Document _doc;
+ mutablebson::Document _doc;
FieldRef _field;
};
@@ -248,7 +248,7 @@ public:
ASSERT_OK(root().pushBack(elemA));
}
- Document& doc() {
+ mutablebson::Document& doc() {
return _doc;
}
@@ -264,7 +264,7 @@ public:
}
private:
- Document _doc;
+ mutablebson::Document _doc;
FieldRef _field;
};
@@ -363,7 +363,7 @@ public:
ASSERT_OK(root().pushBack(elemB));
}
- Document& doc() {
+ mutablebson::Document& doc() {
return _doc;
}
@@ -380,7 +380,7 @@ public:
}
private:
- Document _doc;
+ mutablebson::Document _doc;
FieldRef _field;
};
diff --git a/src/mongo/db/update/pull_node_test.cpp b/src/mongo/db/update/pull_node_test.cpp
index f158b1c0678..9d3c101fba9 100644
--- a/src/mongo/db/update/pull_node_test.cpp
+++ b/src/mongo/db/update/pull_node_test.cpp
@@ -42,7 +42,6 @@ namespace mongo {
namespace {
using PullNodeTest = UpdateNodeTest;
-using mongo::mutablebson::Document;
using mongo::mutablebson::Element;
using mongo::mutablebson::countChildren;
@@ -70,7 +69,7 @@ TEST_F(PullNodeTest, TargetNotFound) {
PullNode node;
ASSERT_OK(node.init(update["$pull"]["a"], collator));
- Document doc(fromjson("{}"));
+ mutablebson::Document doc(fromjson("{}"));
setPathToCreate("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()));
@@ -87,7 +86,7 @@ TEST_F(PullNodeTest, ApplyToStringFails) {
PullNode node;
ASSERT_OK(node.init(update["$pull"]["a"], collator));
- Document doc(fromjson("{a: 'foo'}"));
+ mutablebson::Document doc(fromjson("{a: 'foo'}"));
setPathTaken("a");
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root()["a"])),
@@ -102,7 +101,7 @@ TEST_F(PullNodeTest, ApplyToObjectFails) {
PullNode node;
ASSERT_OK(node.init(update["$pull"]["a"], collator));
- Document doc(fromjson("{a: {foo: 'bar'}}"));
+ mutablebson::Document doc(fromjson("{a: {foo: 'bar'}}"));
setPathTaken("a");
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root()["a"])),
@@ -117,7 +116,7 @@ TEST_F(PullNodeTest, ApplyToNonViablePathFails) {
PullNode node;
ASSERT_OK(node.init(update["$pull"]["a.b"], collator));
- Document doc(fromjson("{a: 1}"));
+ mutablebson::Document doc(fromjson("{a: 1}"));
setPathToCreate("b");
setPathTaken("a");
addIndexedPath("a");
@@ -134,7 +133,7 @@ TEST_F(PullNodeTest, ApplyToMissingElement) {
PullNode node;
ASSERT_OK(node.init(update["$pull"]["a.b.c.d"], collator));
- Document doc(fromjson("{a: {b: {c: {}}}}"));
+ mutablebson::Document doc(fromjson("{a: {b: {c: {}}}}"));
setPathToCreate("d");
setPathTaken("a.b.c");
addIndexedPath("a");
@@ -152,7 +151,7 @@ TEST_F(PullNodeTest, ApplyToEmptyArray) {
PullNode node;
ASSERT_OK(node.init(update["$pull"]["a"], collator));
- Document doc(fromjson("{a: []}"));
+ mutablebson::Document doc(fromjson("{a: []}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -169,7 +168,7 @@ TEST_F(PullNodeTest, ApplyToArrayMatchingNone) {
PullNode node;
ASSERT_OK(node.init(update["$pull"]["a"], collator));
- Document doc(fromjson("{a: [2, 3, 4, 5]}"));
+ mutablebson::Document doc(fromjson("{a: [2, 3, 4, 5]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -186,7 +185,7 @@ TEST_F(PullNodeTest, ApplyToArrayMatchingOne) {
PullNode node;
ASSERT_OK(node.init(update["$pull"]["a"], collator));
- Document doc(fromjson("{a: [0, 1, 2, 3]}"));
+ mutablebson::Document doc(fromjson("{a: [0, 1, 2, 3]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -203,7 +202,7 @@ TEST_F(PullNodeTest, ApplyToArrayMatchingSeveral) {
PullNode node;
ASSERT_OK(node.init(update["$pull"]["a"], collator));
- Document doc(fromjson("{a: [0, 1, 0, 2, 0, 3, 0, 4, 0, 5]}"));
+ mutablebson::Document doc(fromjson("{a: [0, 1, 0, 2, 0, 3, 0, 4, 0, 5]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -220,7 +219,7 @@ TEST_F(PullNodeTest, ApplyToArrayMatchingAll) {
PullNode node;
ASSERT_OK(node.init(update["$pull"]["a"], collator));
- Document doc(fromjson("{a: [0, -1, -2, -3, -4, -5]}"));
+ mutablebson::Document doc(fromjson("{a: [0, -1, -2, -3, -4, -5]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -237,7 +236,7 @@ TEST_F(PullNodeTest, ApplyNoIndexDataNoLogBuilder) {
PullNode node;
ASSERT_OK(node.init(update["$pull"]["a"], collator));
- Document doc(fromjson("{a: [0, 1, 2, 3]}"));
+ mutablebson::Document doc(fromjson("{a: [0, 1, 2, 3]}"));
setPathTaken("a");
setLogBuilderToNull();
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -255,7 +254,7 @@ TEST_F(PullNodeTest, ApplyWithCollation) {
PullNode node;
ASSERT_OK(node.init(update["$pull"]["a"], &collator));
- Document doc(fromjson("{a: ['zaa', 'zcc', 'zbb', 'zee']}"));
+ mutablebson::Document doc(fromjson("{a: ['zaa', 'zcc', 'zbb', 'zee']}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -272,7 +271,7 @@ TEST_F(PullNodeTest, ApplyWithCollationDoesNotAffectNonStringMatches) {
PullNode node;
ASSERT_OK(node.init(update["$pull"]["a"], &collator));
- Document doc(fromjson("{a: [2, 1, 0, -1, -2, -3]}"));
+ mutablebson::Document doc(fromjson("{a: [2, 1, 0, -1, -2, -3]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -289,7 +288,7 @@ TEST_F(PullNodeTest, ApplyWithCollationDoesNotAffectRegexMatches) {
PullNode node;
ASSERT_OK(node.init(update["$pull"]["a"], &collator));
- Document doc(fromjson("{a: ['b', 'a', 'aab', 'cb', 'bba']}"));
+ mutablebson::Document doc(fromjson("{a: ['b', 'a', 'aab', 'cb', 'bba']}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -306,7 +305,7 @@ TEST_F(PullNodeTest, ApplyStringLiteralMatchWithCollation) {
PullNode node;
ASSERT_OK(node.init(update["$pull"]["a"], &collator));
- Document doc(fromjson("{a: ['b', 'a', 'aab', 'cb', 'bba']}"));
+ mutablebson::Document doc(fromjson("{a: ['b', 'a', 'aab', 'cb', 'bba']}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -323,7 +322,7 @@ TEST_F(PullNodeTest, ApplyCollationDoesNotAffectNumberLiteralMatches) {
PullNode node;
ASSERT_OK(node.init(update["$pull"]["a"], &collator));
- Document doc(fromjson("{a: ['a', 99, 'b', 2, 'c', 99, 'd']}"));
+ mutablebson::Document doc(fromjson("{a: ['a', 99, 'b', 2, 'c', 99, 'd']}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -341,7 +340,7 @@ TEST_F(PullNodeTest, ApplyStringMatchAfterSetCollator) {
ASSERT_OK(node.init(update["$pull"]["a"], collator));
// First without a collator.
- Document doc(fromjson("{ a : ['a', 'b', 'c', 'd'] }"));
+ mutablebson::Document doc(fromjson("{ a : ['a', 'b', 'c', 'd'] }"));
setPathTaken("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
ASSERT_FALSE(result.noop);
@@ -352,7 +351,7 @@ TEST_F(PullNodeTest, ApplyStringMatchAfterSetCollator) {
// Now with a collator.
CollatorInterfaceMock mockCollator(CollatorInterfaceMock::MockType::kAlwaysEqual);
node.setCollator(&mockCollator);
- Document doc2(fromjson("{ a : ['a', 'b', 'c', 'd'] }"));
+ mutablebson::Document doc2(fromjson("{ a : ['a', 'b', 'c', 'd'] }"));
resetApplyParams();
setPathTaken("a");
result = node.apply(getApplyParams(doc2.root()["a"]));
@@ -374,7 +373,7 @@ TEST_F(PullNodeTest, SetCollatorDoesNotAffectClone) {
node.setCollator(&mockCollator);
// The original node should now have collation.
- Document doc(fromjson("{ a : ['a', 'b', 'c', 'd'] }"));
+ mutablebson::Document doc(fromjson("{ a : ['a', 'b', 'c', 'd'] }"));
setPathTaken("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
ASSERT_FALSE(result.noop);
@@ -383,7 +382,7 @@ TEST_F(PullNodeTest, SetCollatorDoesNotAffectClone) {
ASSERT_FALSE(doc.isInPlaceModeEnabled());
// The clone should have exact string matches (no collation).
- Document doc2(fromjson("{ a : ['a', 'b', 'c', 'd'] }"));
+ mutablebson::Document doc2(fromjson("{ a : ['a', 'b', 'c', 'd'] }"));
resetApplyParams();
setPathTaken("a");
result = cloneNode->apply(getApplyParams(doc2.root()["a"]));
@@ -403,7 +402,7 @@ TEST_F(PullNodeTest, ApplyComplexDocAndMatching1) {
PullNode node;
ASSERT_OK(node.init(update["$pull"]["a.b"], collator));
- Document doc(fromjson("{a: {b: [{x: 1}, {y: 'y'}, {x: 2}, {z: 'z'}]}}"));
+ mutablebson::Document doc(fromjson("{a: {b: [{x: 1}, {y: 'y'}, {x: 2}, {z: 'z'}]}}"));
setPathTaken("a.b");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]["b"]));
@@ -420,7 +419,7 @@ TEST_F(PullNodeTest, ApplyComplexDocAndMatching2) {
PullNode node;
ASSERT_OK(node.init(update["$pull"]["a.b"], collator));
- Document doc(fromjson("{a: {b: [{x: 1}, {y: 'y'}, {x: 2}, {z: 'z'}]}}"));
+ mutablebson::Document doc(fromjson("{a: {b: [{x: 1}, {y: 'y'}, {x: 2}, {z: 'z'}]}}"));
setPathTaken("a.b");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]["b"]));
@@ -437,7 +436,7 @@ TEST_F(PullNodeTest, ApplyComplexDocAndMatching3) {
PullNode node;
ASSERT_OK(node.init(update["$pull"]["a.b"], collator));
- Document doc(fromjson("{a: {b: [{x: 1}, {y: 'y'}, {x: 2}, {z: 'z'}]}}"));
+ mutablebson::Document doc(fromjson("{a: {b: [{x: 1}, {y: 'y'}, {x: 2}, {z: 'z'}]}}"));
setPathTaken("a.b");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]["b"]));
@@ -454,7 +453,8 @@ TEST_F(PullNodeTest, ApplyFullPredicateWithCollation) {
PullNode node;
ASSERT_OK(node.init(update["$pull"]["a.b"], &collator));
- Document doc(fromjson("{a: {b: [{x: 'foo', y: 1}, {x: 'bar', y: 2}, {x: 'baz', y: 3}]}}"));
+ mutablebson::Document doc(
+ fromjson("{a: {b: [{x: 'foo', y: 1}, {x: 'bar', y: 2}, {x: 'baz', y: 3}]}}"));
setPathTaken("a.b");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]["b"]));
@@ -471,7 +471,7 @@ TEST_F(PullNodeTest, ApplyScalarValueMod) {
PullNode node;
ASSERT_OK(node.init(update["$pull"]["a"], collator));
- Document doc(fromjson("{a: [1, 2, 1, 2, 1, 2]}"));
+ mutablebson::Document doc(fromjson("{a: [1, 2, 1, 2, 1, 2]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -488,7 +488,7 @@ TEST_F(PullNodeTest, ApplyObjectValueMod) {
PullNode node;
ASSERT_OK(node.init(update["$pull"]["a"], collator));
- Document doc(fromjson("{a: [{x: 1}, {y: 2}, {x: 1}, {y: 2}]}"));
+ mutablebson::Document doc(fromjson("{a: [{x: 1}, {y: 2}, {x: 1}, {y: 2}]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -505,7 +505,8 @@ TEST_F(PullNodeTest, DocumentationExample1) {
PullNode node;
ASSERT_OK(node.init(update["$pull"]["flags"], collator));
- Document doc(fromjson("{flags: ['vme', 'de', 'pse', 'tsc', 'msr', 'pae', 'mce']}"));
+ mutablebson::Document doc(
+ fromjson("{flags: ['vme', 'de', 'pse', 'tsc', 'msr', 'pae', 'mce']}"));
setPathTaken("flags");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["flags"]));
@@ -523,7 +524,7 @@ TEST_F(PullNodeTest, DocumentationExample2a) {
PullNode node;
ASSERT_OK(node.init(update["$pull"]["votes"], collator));
- Document doc(fromjson("{votes: [3, 5, 6, 7, 7, 8]}"));
+ mutablebson::Document doc(fromjson("{votes: [3, 5, 6, 7, 7, 8]}"));
setPathTaken("votes");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["votes"]));
@@ -540,7 +541,7 @@ TEST_F(PullNodeTest, DocumentationExample2b) {
PullNode node;
ASSERT_OK(node.init(update["$pull"]["votes"], collator));
- Document doc(fromjson("{votes: [3, 5, 6, 7, 7, 8]}"));
+ mutablebson::Document doc(fromjson("{votes: [3, 5, 6, 7, 7, 8]}"));
setPathTaken("votes");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["votes"]));
@@ -557,7 +558,7 @@ TEST_F(PullNodeTest, ApplyPullWithObjectValueToArrayWithNonObjectValue) {
PullNode node;
ASSERT_OK(node.init(update["$pull"]["a"], collator));
- Document doc(fromjson("{a: [{x: 1}, 2]}"));
+ mutablebson::Document doc(fromjson("{a: [{x: 1}, 2]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -574,7 +575,7 @@ TEST_F(PullNodeTest, CannotModifyImmutableField) {
PullNode node;
ASSERT_OK(node.init(update["$pull"]["_id.a"], collator));
- Document doc(fromjson("{_id: {a: [0, 1, 2]}}"));
+ mutablebson::Document doc(fromjson("{_id: {a: [0, 1, 2]}}"));
setPathTaken("_id.a");
addImmutablePath("_id");
ASSERT_THROWS_CODE_AND_WHAT(
@@ -590,7 +591,7 @@ TEST_F(PullNodeTest, SERVER_3988) {
PullNode node;
ASSERT_OK(node.init(update["$pull"]["y"], collator));
- Document doc(fromjson("{x: 1, y: [2, 3, 4, 'abc', 'xyz']}"));
+ mutablebson::Document doc(fromjson("{x: 1, y: [2, 3, 4, 'abc', 'xyz']}"));
setPathTaken("y");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["y"]));
diff --git a/src/mongo/db/update/pullall_node_test.cpp b/src/mongo/db/update/pullall_node_test.cpp
index 1928b5f6223..4af970eb306 100644
--- a/src/mongo/db/update/pullall_node_test.cpp
+++ b/src/mongo/db/update/pullall_node_test.cpp
@@ -42,7 +42,6 @@ namespace mongo {
namespace {
using PullAllNodeTest = UpdateNodeTest;
-using mongo::mutablebson::Document;
using mongo::mutablebson::Element;
using mongo::mutablebson::countChildren;
@@ -88,7 +87,7 @@ TEST_F(PullAllNodeTest, TargetNotFound) {
PullAllNode node;
ASSERT_OK(node.init(update["$pullAll"]["b"], collator));
- Document doc(fromjson("{a: [1, 'a', {r: 1, b: 2}]}"));
+ mutablebson::Document doc(fromjson("{a: [1, 'a', {r: 1, b: 2}]}"));
setPathToCreate("b");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()));
@@ -105,7 +104,7 @@ TEST_F(PullAllNodeTest, TargetArrayElementNotFound) {
PullAllNode node;
ASSERT_OK(node.init(update["$pullAll"]["a.2"], collator));
- Document doc(fromjson("{a: [1, 2]}"));
+ mutablebson::Document doc(fromjson("{a: [1, 2]}"));
setPathToCreate("2");
setPathTaken("a");
addIndexedPath("a");
@@ -123,7 +122,7 @@ TEST_F(PullAllNodeTest, ApplyToNonArrayFails) {
PullAllNode node;
ASSERT_OK(node.init(update["$pullAll"]["a.0"], collator));
- Document doc(fromjson("{a: [1, 2]}"));
+ mutablebson::Document doc(fromjson("{a: [1, 2]}"));
setPathTaken("a.0");
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root()["a"][0])),
@@ -138,7 +137,7 @@ TEST_F(PullAllNodeTest, ApplyWithSingleNumber) {
PullAllNode node;
ASSERT_OK(node.init(update["$pullAll"]["a"], collator));
- Document doc(fromjson("{a: [1, 'a', {r: 1, b: 2}]}"));
+ mutablebson::Document doc(fromjson("{a: [1, 'a', {r: 1, b: 2}]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -155,7 +154,7 @@ TEST_F(PullAllNodeTest, ApplyNoIndexDataNoLogBuilder) {
PullAllNode node;
ASSERT_OK(node.init(update["$pullAll"]["a"], collator));
- Document doc(fromjson("{a: [1, 'a', {r: 1, b: 2}]}"));
+ mutablebson::Document doc(fromjson("{a: [1, 'a', {r: 1, b: 2}]}"));
setPathTaken("a");
setLogBuilderToNull();
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -171,7 +170,7 @@ TEST_F(PullAllNodeTest, ApplyWithElementNotPresentInArray) {
PullAllNode node;
ASSERT_OK(node.init(update["$pullAll"]["a"], collator));
- Document doc(fromjson("{a: [1, 'a', {r: 1, b: 2}]}"));
+ mutablebson::Document doc(fromjson("{a: [1, 'a', {r: 1, b: 2}]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -188,7 +187,7 @@ TEST_F(PullAllNodeTest, ApplyWithWithTwoElements) {
PullAllNode node;
ASSERT_OK(node.init(update["$pullAll"]["a"], collator));
- Document doc(fromjson("{a: [1, 'a', {r: 1, b: 2}]}"));
+ mutablebson::Document doc(fromjson("{a: [1, 'a', {r: 1, b: 2}]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -205,7 +204,7 @@ TEST_F(PullAllNodeTest, ApplyWithAllArrayElements) {
PullAllNode node;
ASSERT_OK(node.init(update["$pullAll"]["a"], collator));
- Document doc(fromjson("{a: [1, 'a', {r: 1, b: 2}]}"));
+ mutablebson::Document doc(fromjson("{a: [1, 'a', {r: 1, b: 2}]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -222,7 +221,7 @@ TEST_F(PullAllNodeTest, ApplyWithAllArrayElementsButOutOfOrder) {
PullAllNode node;
ASSERT_OK(node.init(update["$pullAll"]["a"], collator));
- Document doc(fromjson("{a: [1, 'a', {r: 1, b: 2}]}"));
+ mutablebson::Document doc(fromjson("{a: [1, 'a', {r: 1, b: 2}]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -239,7 +238,7 @@ TEST_F(PullAllNodeTest, ApplyWithAllArrayElementsAndThenSome) {
PullAllNode node;
ASSERT_OK(node.init(update["$pullAll"]["a"], collator));
- Document doc(fromjson("{a: [1, 'a', {r: 1, b: 2}]}"));
+ mutablebson::Document doc(fromjson("{a: [1, 'a', {r: 1, b: 2}]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -256,7 +255,7 @@ TEST_F(PullAllNodeTest, ApplyWithCollator) {
PullAllNode node;
ASSERT_OK(node.init(update["$pullAll"]["a"], &collator));
- Document doc(fromjson("{a: ['foo', 'bar', 'baz']}"));
+ mutablebson::Document doc(fromjson("{a: ['foo', 'bar', 'baz']}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -274,7 +273,7 @@ TEST_F(PullAllNodeTest, ApplyAfterSetCollator) {
ASSERT_OK(node.init(update["$pullAll"]["a"], collator));
// First without a collator.
- Document doc(fromjson("{a: ['foo', 'bar', 'baz']}"));
+ mutablebson::Document doc(fromjson("{a: ['foo', 'bar', 'baz']}"));
setPathTaken("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
ASSERT_TRUE(result.noop);
@@ -284,7 +283,7 @@ TEST_F(PullAllNodeTest, ApplyAfterSetCollator) {
// Now with a collator.
CollatorInterfaceMock mockCollator(CollatorInterfaceMock::MockType::kToLowerString);
node.setCollator(&mockCollator);
- Document doc2(fromjson("{a: ['foo', 'bar', 'baz']}"));
+ mutablebson::Document doc2(fromjson("{a: ['foo', 'bar', 'baz']}"));
resetApplyParams();
setPathTaken("a");
result = node.apply(getApplyParams(doc2.root()["a"]));
diff --git a/src/mongo/db/update/push_node_test.cpp b/src/mongo/db/update/push_node_test.cpp
index a06b26484bd..ba9e988fb64 100644
--- a/src/mongo/db/update/push_node_test.cpp
+++ b/src/mongo/db/update/push_node_test.cpp
@@ -42,7 +42,6 @@ namespace mongo {
namespace {
using PushNodeTest = UpdateNodeTest;
-using mongo::mutablebson::Document;
using mongo::mutablebson::Element;
using mongo::mutablebson::countChildren;
@@ -262,7 +261,7 @@ TEST_F(PushNodeTest, ApplyToNonArrayFails) {
PushNode node;
ASSERT_OK(node.init(update["$push"]["a"], collator));
- Document doc(fromjson("{_id: 'test_object', a: 1}"));
+ mutablebson::Document doc(fromjson("{_id: 'test_object', a: 1}"));
setPathTaken("a");
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(
@@ -278,7 +277,7 @@ TEST_F(PushNodeTest, ApplyToEmptyArray) {
PushNode node;
ASSERT_OK(node.init(update["$push"]["a"], collator));
- Document doc(fromjson("{a: []}"));
+ mutablebson::Document doc(fromjson("{a: []}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -295,7 +294,7 @@ TEST_F(PushNodeTest, ApplyToEmptyDocument) {
PushNode node;
ASSERT_OK(node.init(update["$push"]["a"], collator));
- Document doc(fromjson("{}"));
+ mutablebson::Document doc(fromjson("{}"));
setPathToCreate("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()));
@@ -312,7 +311,7 @@ TEST_F(PushNodeTest, ApplyToArrayWithOneElement) {
PushNode node;
ASSERT_OK(node.init(update["$push"]["a"], collator));
- Document doc(fromjson("{a: [0]}"));
+ mutablebson::Document doc(fromjson("{a: [0]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -329,7 +328,7 @@ TEST_F(PushNodeTest, ApplyToDottedPathElement) {
PushNode node;
ASSERT_OK(node.init(update["$push"]["choices.first.votes"], collator));
- Document doc(
+ mutablebson::Document doc(
fromjson("{_id : 1 , "
" question : 'a', "
" choices: {first: { choice: 'b'}, "
@@ -357,7 +356,7 @@ TEST_F(PushNodeTest, ApplySimpleEachToEmptyArray) {
PushNode node;
ASSERT_OK(node.init(update["$push"]["a"], collator));
- Document doc(fromjson("{a: []}"));
+ mutablebson::Document doc(fromjson("{a: []}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -374,7 +373,7 @@ TEST_F(PushNodeTest, ApplySimpleEachToEmptyDocument) {
PushNode node;
ASSERT_OK(node.init(update["$push"]["a"], collator));
- Document doc(fromjson("{}"));
+ mutablebson::Document doc(fromjson("{}"));
setPathToCreate("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()));
@@ -391,7 +390,7 @@ TEST_F(PushNodeTest, ApplyMultipleEachToEmptyDocument) {
PushNode node;
ASSERT_OK(node.init(update["$push"]["a"], collator));
- Document doc(fromjson("{}"));
+ mutablebson::Document doc(fromjson("{}"));
setPathToCreate("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()));
@@ -408,7 +407,7 @@ TEST_F(PushNodeTest, ApplySimpleEachToArrayWithOneElement) {
PushNode node;
ASSERT_OK(node.init(update["$push"]["a"], collator));
- Document doc(fromjson("{a: [0]}"));
+ mutablebson::Document doc(fromjson("{a: [0]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -425,7 +424,7 @@ TEST_F(PushNodeTest, ApplyMultipleEachToArrayWithOneElement) {
PushNode node;
ASSERT_OK(node.init(update["$push"]["a"], collator));
- Document doc(fromjson("{a: [0]}"));
+ mutablebson::Document doc(fromjson("{a: [0]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -442,7 +441,7 @@ TEST_F(PushNodeTest, ApplyEmptyEachToEmptyArray) {
PushNode node;
ASSERT_OK(node.init(update["$push"]["a"], collator));
- Document doc(fromjson("{a: []}"));
+ mutablebson::Document doc(fromjson("{a: []}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -459,7 +458,7 @@ TEST_F(PushNodeTest, ApplyEmptyEachToEmptyDocument) {
PushNode node;
ASSERT_OK(node.init(update["$push"]["a"], collator));
- Document doc(fromjson("{}"));
+ mutablebson::Document doc(fromjson("{}"));
setPathToCreate("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()));
@@ -476,7 +475,7 @@ TEST_F(PushNodeTest, ApplyEmptyEachToArrayWithOneElement) {
PushNode node;
ASSERT_OK(node.init(update["$push"]["a"], collator));
- Document doc(fromjson("{a: [0]}"));
+ mutablebson::Document doc(fromjson("{a: [0]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -493,7 +492,7 @@ TEST_F(PushNodeTest, ApplyToArrayWithSlice) {
PushNode node;
ASSERT_OK(node.init(update["$push"]["a"], collator));
- Document doc(fromjson("{a: [3]}"));
+ mutablebson::Document doc(fromjson("{a: [3]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -510,7 +509,7 @@ TEST_F(PushNodeTest, ApplyWithNumericSort) {
PushNode node;
ASSERT_OK(node.init(update["$push"]["a"], collator));
- Document doc(fromjson("{a: [3]}"));
+ mutablebson::Document doc(fromjson("{a: [3]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -527,7 +526,7 @@ TEST_F(PushNodeTest, ApplyWithReverseNumericSort) {
PushNode node;
ASSERT_OK(node.init(update["$push"]["a"], collator));
- Document doc(fromjson("{a: [3]}"));
+ mutablebson::Document doc(fromjson("{a: [3]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -544,7 +543,7 @@ TEST_F(PushNodeTest, ApplyWithMixedSort) {
PushNode node;
ASSERT_OK(node.init(update["$push"]["a"], collator));
- Document doc(fromjson("{a: [3, 't', {b: 1}, {a: 1}]}"));
+ mutablebson::Document doc(fromjson("{a: [3, 't', {b: 1}, {a: 1}]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -561,7 +560,7 @@ TEST_F(PushNodeTest, ApplyWithReverseMixedSort) {
PushNode node;
ASSERT_OK(node.init(update["$push"]["a"], collator));
- Document doc(fromjson("{a: [3, 't', {b: 1}, {a: 1}]}"));
+ mutablebson::Document doc(fromjson("{a: [3, 't', {b: 1}, {a: 1}]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -578,7 +577,7 @@ TEST_F(PushNodeTest, ApplyWithEmbeddedFieldSort) {
PushNode node;
ASSERT_OK(node.init(update["$push"]["a"], collator));
- Document doc(fromjson("{a: [3, 't', {b: 1}, {a: 1}]}"));
+ mutablebson::Document doc(fromjson("{a: [3, 't', {b: 1}, {a: 1}]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -595,7 +594,7 @@ TEST_F(PushNodeTest, ApplySortWithCollator) {
PushNode node;
ASSERT_OK(node.init(update["$push"]["a"], &collator));
- Document doc(fromjson("{a: ['dd', 'fc', 'gb']}"));
+ mutablebson::Document doc(fromjson("{a: ['dd', 'fc', 'gb']}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -612,7 +611,7 @@ TEST_F(PushNodeTest, ApplySortAfterSetCollator) {
PushNode node;
ASSERT_OK(node.init(update["$push"]["a"], collator));
- Document doc(fromjson("{a: ['dd', 'fc', 'gb']}"));
+ mutablebson::Document doc(fromjson("{a: ['dd', 'fc', 'gb']}"));
setPathTaken("a");
setLogBuilderToNull();
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -623,7 +622,7 @@ TEST_F(PushNodeTest, ApplySortAfterSetCollator) {
// Now with a collator.
CollatorInterfaceMock mockCollator(CollatorInterfaceMock::MockType::kReverseString);
node.setCollator(&mockCollator);
- Document doc2(fromjson("{a: ['dd', 'fc', 'gb']}"));
+ mutablebson::Document doc2(fromjson("{a: ['dd', 'fc', 'gb']}"));
result = node.apply(getApplyParams(doc2.root()["a"]));
ASSERT_FALSE(result.noop);
ASSERT_EQUALS(fromjson("{a: ['ha', 'gb', 'fc', 'dd']}"), doc2);
@@ -634,7 +633,7 @@ TEST_F(PushNodeTest, ApplySortAfterSetCollator) {
// prints out the modifier when it observes a failure, which will help with diagnosis.
void checkDocumentAndResult(BSONObj updateModifier,
BSONObj expectedDocument,
- const Document& actualDocument,
+ const mutablebson::Document& actualDocument,
UpdateNode::ApplyResult applyResult) {
if (expectedDocument == actualDocument && !applyResult.noop && !applyResult.indexesAffected) {
// Check succeeded.
@@ -671,7 +670,7 @@ TEST_F(PushNodeTest, ApplyToEmptyArrayWithSliceValues) {
PushNode node;
ASSERT_OK(node.init(update["$push"]["a"], collator));
- Document doc(fromjson("{a: []}"));
+ mutablebson::Document doc(fromjson("{a: []}"));
setPathTaken("a");
setLogBuilderToNull();
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -703,7 +702,7 @@ TEST_F(PushNodeTest, ApplyToPopulatedArrayWithSliceValues) {
PushNode node;
ASSERT_OK(node.init(update["$push"]["a"], collator));
- Document doc(fromjson("{a: [2, 3]}"));
+ mutablebson::Document doc(fromjson("{a: [2, 3]}"));
setPathTaken("a");
setLogBuilderToNull();
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -804,7 +803,7 @@ TEST_F(PushNodeTest, ApplyToPopulatedArrayWithSortAndSliceValues) {
PushNode node;
ASSERT_OK(node.init(update["$push"]["a"], collator));
- Document doc(fromjson("{a: [{a: 2, b: 3}, {a: 3, b: 1}]}"));
+ mutablebson::Document doc(fromjson("{a: [{a: 2, b: 3}, {a: 3, b: 1}]}"));
setPathTaken("a");
setLogBuilderToNull();
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -818,7 +817,7 @@ TEST_F(PushNodeTest, ApplyToEmptyArrayWithPositionZero) {
PushNode node;
ASSERT_OK(node.init(update["$push"]["a"], collator));
- Document doc(fromjson("{a: []}"));
+ mutablebson::Document doc(fromjson("{a: []}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -835,7 +834,7 @@ TEST_F(PushNodeTest, ApplyToEmptyArrayWithPositionOne) {
PushNode node;
ASSERT_OK(node.init(update["$push"]["a"], collator));
- Document doc(fromjson("{a: []}"));
+ mutablebson::Document doc(fromjson("{a: []}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -852,7 +851,7 @@ TEST_F(PushNodeTest, ApplyToEmptyArrayWithLargePosition) {
PushNode node;
ASSERT_OK(node.init(update["$push"]["a"], collator));
- Document doc(fromjson("{a: []}"));
+ mutablebson::Document doc(fromjson("{a: []}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -869,7 +868,7 @@ TEST_F(PushNodeTest, ApplyToSingletonArrayWithPositionZero) {
PushNode node;
ASSERT_OK(node.init(update["$push"]["a"], collator));
- Document doc(fromjson("{a: [0]}"));
+ mutablebson::Document doc(fromjson("{a: [0]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -886,7 +885,7 @@ TEST_F(PushNodeTest, ApplyToSingletonArrayWithLargePosition) {
PushNode node;
ASSERT_OK(node.init(update["$push"]["a"], collator));
- Document doc(fromjson("{a: [0]}"));
+ mutablebson::Document doc(fromjson("{a: [0]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -903,7 +902,7 @@ TEST_F(PushNodeTest, ApplyToEmptyArrayWithNegativePosition) {
PushNode node;
ASSERT_OK(node.init(update["$push"]["a"], collator));
- Document doc(fromjson("{a: []}"));
+ mutablebson::Document doc(fromjson("{a: []}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -920,7 +919,7 @@ TEST_F(PushNodeTest, ApplyToSingletonArrayWithNegativePosition) {
PushNode node;
ASSERT_OK(node.init(update["$push"]["a"], collator));
- Document doc(fromjson("{a: [0]}"));
+ mutablebson::Document doc(fromjson("{a: [0]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -937,7 +936,7 @@ TEST_F(PushNodeTest, ApplyToPopulatedArrayWithNegativePosition) {
PushNode node;
ASSERT_OK(node.init(update["$push"]["a"], collator));
- Document doc(fromjson("{a: [0, 1, 2, 3, 4]}"));
+ mutablebson::Document doc(fromjson("{a: [0, 1, 2, 3, 4]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -954,7 +953,7 @@ TEST_F(PushNodeTest, ApplyToPopulatedArrayWithOutOfBoundsNegativePosition) {
PushNode node;
ASSERT_OK(node.init(update["$push"]["a"], collator));
- Document doc(fromjson("{a: [0, 1, 2, 3, 4]}"));
+ mutablebson::Document doc(fromjson("{a: [0, 1, 2, 3, 4]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -971,7 +970,7 @@ TEST_F(PushNodeTest, ApplyMultipleElementsPushWithNegativePosition) {
PushNode node;
ASSERT_OK(node.init(update["$push"]["a"], collator));
- Document doc(fromjson("{a: [0, 1, 2, 3, 4]}"));
+ mutablebson::Document doc(fromjson("{a: [0, 1, 2, 3, 4]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
diff --git a/src/mongo/db/update/push_sorter_test.cpp b/src/mongo/db/update/push_sorter_test.cpp
index 42cc0f3783d..611f4e80206 100644
--- a/src/mongo/db/update/push_sorter_test.cpp
+++ b/src/mongo/db/update/push_sorter_test.cpp
@@ -40,7 +40,6 @@
namespace mongo {
namespace {
-using mongo::mutablebson::Document;
using mongo::mutablebson::Element;
using mongo::mutablebson::sortChildren;
@@ -75,7 +74,7 @@ public:
}
private:
- Document _doc;
+ mutablebson::Document _doc;
BSONObj _objs[3];
size_t _size;
};
diff --git a/src/mongo/db/update/rename_node_test.cpp b/src/mongo/db/update/rename_node_test.cpp
index 84f46f0651f..a72485b7e23 100644
--- a/src/mongo/db/update/rename_node_test.cpp
+++ b/src/mongo/db/update/rename_node_test.cpp
@@ -41,7 +41,6 @@ namespace mongo {
namespace {
using RenameNodeTest = UpdateNodeTest;
-using mongo::mutablebson::Document;
using mongo::mutablebson::Element;
using mongo::mutablebson::countChildren;
@@ -115,7 +114,7 @@ TEST_F(RenameNodeTest, SimpleNumberAtRoot) {
RenameNode node;
ASSERT_OK(node.init(update["$rename"]["a"], collator));
- Document doc(fromjson("{a: 2}"));
+ mutablebson::Document doc(fromjson("{a: 2}"));
setPathToCreate("b");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()));
@@ -131,7 +130,7 @@ TEST_F(RenameNodeTest, ToExistsAtSameLevel) {
RenameNode node;
ASSERT_OK(node.init(update["$rename"]["a"], collator));
- Document doc(fromjson("{a: 2, b: 1}"));
+ mutablebson::Document doc(fromjson("{a: 2, b: 1}"));
setPathTaken("b");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["b"]));
@@ -147,7 +146,7 @@ TEST_F(RenameNodeTest, ToAndFromHaveSameValue) {
RenameNode node;
ASSERT_OK(node.init(update["$rename"]["a"], collator));
- Document doc(fromjson("{a: 2, b: 2}"));
+ mutablebson::Document doc(fromjson("{a: 2, b: 2}"));
setPathTaken("b");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["b"]));
@@ -163,7 +162,7 @@ TEST_F(RenameNodeTest, FromDottedElement) {
RenameNode node;
ASSERT_OK(node.init(update["$rename"]["a.c"], collator));
- Document doc(fromjson("{a: {c: {d: 6}}, b: 1}"));
+ mutablebson::Document doc(fromjson("{a: {c: {d: 6}}, b: 1}"));
setPathTaken("b");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["b"]));
@@ -179,7 +178,7 @@ TEST_F(RenameNodeTest, RenameToExistingNestedFieldDoesNotReorderFields) {
RenameNode node;
ASSERT_OK(node.init(update["$rename"]["c.d"], collator));
- Document doc(fromjson("{a: {b: {c: 1, d: 2}}, b: 3, c: {d: 4}}"));
+ mutablebson::Document doc(fromjson("{a: {b: {c: 1, d: 2}}, b: 3, c: {d: 4}}"));
setPathTaken("a.b.c");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]["b"]["c"]));
@@ -195,7 +194,7 @@ TEST_F(RenameNodeTest, MissingCompleteTo) {
RenameNode node;
ASSERT_OK(node.init(update["$rename"]["a"], collator));
- Document doc(fromjson("{a: 2, b: 1, c: {}}"));
+ mutablebson::Document doc(fromjson("{a: 2, b: 1, c: {}}"));
setPathToCreate("r.d");
setPathTaken("c");
addIndexedPath("a");
@@ -212,7 +211,7 @@ TEST_F(RenameNodeTest, ToIsCompletelyMissing) {
RenameNode node;
ASSERT_OK(node.init(update["$rename"]["a"], collator));
- Document doc(fromjson("{a: 2}"));
+ mutablebson::Document doc(fromjson("{a: 2}"));
setPathToCreate("b.c.d");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()));
@@ -228,7 +227,7 @@ TEST_F(RenameNodeTest, ToMissingDottedField) {
RenameNode node;
ASSERT_OK(node.init(update["$rename"]["a"], collator));
- Document doc(fromjson("{a: [{a:2, b:1}]}"));
+ mutablebson::Document doc(fromjson("{a: [{a:2, b:1}]}"));
setPathToCreate("b.c.d");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()));
@@ -244,7 +243,7 @@ TEST_F(RenameNodeTest, MoveIntoArray) {
RenameNode node;
ASSERT_OK(node.init(update["$rename"]["b"], collator));
- Document doc(fromjson("{_id: 'test_object', a: [1, 2], b: 2}"));
+ mutablebson::Document doc(fromjson("{_id: 'test_object', a: [1, 2], b: 2}"));
setPathToCreate("2");
setPathTaken("a");
addIndexedPath("a");
@@ -261,7 +260,7 @@ TEST_F(RenameNodeTest, MoveIntoArrayNoId) {
RenameNode node;
ASSERT_OK(node.init(update["$rename"]["b"], collator));
- Document doc(fromjson("{a: [1, 2], b: 2}"));
+ mutablebson::Document doc(fromjson("{a: [1, 2], b: 2}"));
setPathToCreate("2");
setPathTaken("a");
addIndexedPath("a");
@@ -278,7 +277,7 @@ TEST_F(RenameNodeTest, MoveToArrayElement) {
RenameNode node;
ASSERT_OK(node.init(update["$rename"]["b"], collator));
- Document doc(fromjson("{_id: 'test_object', a: [1, 2], b: 2}"));
+ mutablebson::Document doc(fromjson("{_id: 'test_object', a: [1, 2], b: 2}"));
setPathTaken("a.1");
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root()["a"]["1"])),
@@ -294,7 +293,7 @@ TEST_F(RenameNodeTest, MoveOutOfArray) {
RenameNode node;
ASSERT_OK(node.init(update["$rename"]["a.0"], collator));
- Document doc(fromjson("{_id: 'test_object', a: [1, 2]}"));
+ mutablebson::Document doc(fromjson("{_id: 'test_object', a: [1, 2]}"));
setPathToCreate("b");
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root())),
@@ -310,7 +309,7 @@ TEST_F(RenameNodeTest, MoveNonexistentEmbeddedFieldOut) {
RenameNode node;
ASSERT_OK(node.init(update["$rename"]["a.a"], collator));
- Document doc(fromjson("{a: [{a: 1}, {b: 2}]}"));
+ mutablebson::Document doc(fromjson("{a: [{a: 1}, {b: 2}]}"));
setPathToCreate("b");
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(
@@ -326,7 +325,7 @@ TEST_F(RenameNodeTest, MoveEmbeddedFieldOutWithElementNumber) {
RenameNode node;
ASSERT_OK(node.init(update["$rename"]["a.0.a"], collator));
- Document doc(fromjson("{_id: 'test_object', a: [{a: 1}, {b: 2}]}"));
+ mutablebson::Document doc(fromjson("{_id: 'test_object', a: [{a: 1}, {b: 2}]}"));
setPathToCreate("b");
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root())),
@@ -342,7 +341,7 @@ TEST_F(RenameNodeTest, ReplaceArrayField) {
RenameNode node;
ASSERT_OK(node.init(update["$rename"]["a"], collator));
- Document doc(fromjson("{a: 2, b: []}"));
+ mutablebson::Document doc(fromjson("{a: 2, b: []}"));
setPathTaken("b");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["b"]));
@@ -358,7 +357,7 @@ TEST_F(RenameNodeTest, ReplaceWithArrayField) {
RenameNode node;
ASSERT_OK(node.init(update["$rename"]["a"], collator));
- Document doc(fromjson("{a: [], b: 2}"));
+ mutablebson::Document doc(fromjson("{a: [], b: 2}"));
setPathTaken("b");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["b"]));
@@ -374,7 +373,7 @@ TEST_F(RenameNodeTest, CanRenameFromInvalidFieldName) {
RenameNode node;
ASSERT_OK(node.init(update["$rename"]["$a"], collator));
- Document doc(fromjson("{$a: 2}"));
+ mutablebson::Document doc(fromjson("{$a: 2}"));
setPathToCreate("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()));
@@ -390,7 +389,7 @@ TEST_F(RenameNodeTest, RenameWithoutLogBuilderOrIndexData) {
RenameNode node;
ASSERT_OK(node.init(update["$rename"]["a"], collator));
- Document doc(fromjson("{a: 2}"));
+ mutablebson::Document doc(fromjson("{a: 2}"));
setPathToCreate("b");
setLogBuilderToNull();
auto result = node.apply(getApplyParams(doc.root()));
@@ -404,7 +403,7 @@ TEST_F(RenameNodeTest, RenameFromNonExistentPathIsNoOp) {
RenameNode node;
ASSERT_OK(node.init(update["$rename"]["a"], collator));
- Document doc(fromjson("{b: 2}"));
+ mutablebson::Document doc(fromjson("{b: 2}"));
setPathTaken("b");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["b"]));
@@ -420,7 +419,7 @@ TEST_F(RenameNodeTest, ApplyCannotRemoveRequiredPartOfDBRef) {
RenameNode node;
ASSERT_OK(node.init(update["$rename"]["a.$id"], collator));
- Document doc(fromjson("{a: {$ref: 'c', $id: 0}}"));
+ mutablebson::Document doc(fromjson("{a: {$ref: 'c', $id: 0}}"));
setPathToCreate("b");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root())),
UserException,
@@ -434,7 +433,7 @@ TEST_F(RenameNodeTest, ApplyCanRemoveRequiredPartOfDBRefIfValidateForStorageIsFa
RenameNode node;
ASSERT_OK(node.init(update["$rename"]["a.$id"], collator));
- Document doc(fromjson("{a: {$ref: 'c', $id: 0}}"));
+ mutablebson::Document doc(fromjson("{a: {$ref: 'c', $id: 0}}"));
setPathToCreate("b");
addIndexedPath("a");
setValidateForStorage(false);
@@ -456,7 +455,7 @@ TEST_F(RenameNodeTest, ApplyCannotRemoveImmutablePath) {
RenameNode node;
ASSERT_OK(node.init(update["$rename"]["a.b"], collator));
- Document doc(fromjson("{a: {b: 1}}"));
+ mutablebson::Document doc(fromjson("{a: {b: 1}}"));
setPathToCreate("c");
addImmutablePath("a.b");
ASSERT_THROWS_CODE_AND_WHAT(
@@ -472,7 +471,7 @@ TEST_F(RenameNodeTest, ApplyCannotRemovePrefixOfImmutablePath) {
RenameNode node;
ASSERT_OK(node.init(update["$rename"]["a"], collator));
- Document doc(fromjson("{a: {b: 1}}"));
+ mutablebson::Document doc(fromjson("{a: {b: 1}}"));
setPathToCreate("c");
addImmutablePath("a.b");
ASSERT_THROWS_CODE_AND_WHAT(
@@ -488,7 +487,7 @@ TEST_F(RenameNodeTest, ApplyCannotRemoveSuffixOfImmutablePath) {
RenameNode node;
ASSERT_OK(node.init(update["$rename"]["a.b.c"], collator));
- Document doc(fromjson("{a: {b: {c: 1}}}"));
+ mutablebson::Document doc(fromjson("{a: {b: {c: 1}}}"));
setPathToCreate("d");
addImmutablePath("a.b");
ASSERT_THROWS_CODE_AND_WHAT(
@@ -504,7 +503,7 @@ TEST_F(RenameNodeTest, ApplyCanRemoveImmutablePathIfNoop) {
RenameNode node;
ASSERT_OK(node.init(update["$rename"]["a.b.c"], collator));
- Document doc(fromjson("{a: {b: {}}}"));
+ mutablebson::Document doc(fromjson("{a: {b: {}}}"));
setPathToCreate("d");
addImmutablePath("a.b");
addIndexedPath("a");
@@ -522,7 +521,7 @@ TEST_F(RenameNodeTest, ApplyCannotCreateDollarPrefixedField) {
RenameNode node;
ASSERT_OK(node.init(update["$rename"]["a"], collator));
- Document doc(fromjson("{a: 0}"));
+ mutablebson::Document doc(fromjson("{a: 0}"));
setPathToCreate("$bad");
ASSERT_THROWS_CODE_AND_WHAT(
node.apply(getApplyParams(doc.root())),
@@ -537,7 +536,7 @@ TEST_F(RenameNodeTest, ApplyCannotOverwriteImmutablePath) {
RenameNode node;
ASSERT_OK(node.init(update["$rename"]["a"], collator));
- Document doc(fromjson("{a: 0, b: 1}"));
+ mutablebson::Document doc(fromjson("{a: 0, b: 1}"));
setPathTaken("b");
addImmutablePath("b");
ASSERT_THROWS_CODE_AND_WHAT(
diff --git a/src/mongo/db/update/set_node_test.cpp b/src/mongo/db/update/set_node_test.cpp
index 3d90d27b6c5..a7a6f793a10 100644
--- a/src/mongo/db/update/set_node_test.cpp
+++ b/src/mongo/db/update/set_node_test.cpp
@@ -41,7 +41,6 @@ namespace mongo {
namespace {
using SetNodeTest = UpdateNodeTest;
-using mongo::mutablebson::Document;
using mongo::mutablebson::Element;
using mongo::mutablebson::countChildren;
@@ -65,7 +64,7 @@ TEST_F(SetNodeTest, ApplyNoOp) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a"], collator));
- Document doc(fromjson("{a: 5}"));
+ mutablebson::Document doc(fromjson("{a: 5}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -82,7 +81,7 @@ TEST_F(SetNodeTest, ApplyEmptyPathToCreate) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a"], collator));
- Document doc(fromjson("{a: 5}"));
+ mutablebson::Document doc(fromjson("{a: 5}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -99,7 +98,7 @@ TEST_F(SetNodeTest, ApplyCreatePath) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.b.c"], collator));
- Document doc(fromjson("{a: {d: 5}}"));
+ mutablebson::Document doc(fromjson("{a: {d: 5}}"));
setPathToCreate("b.c");
setPathTaken("a");
addIndexedPath("a");
@@ -117,7 +116,7 @@ TEST_F(SetNodeTest, ApplyCreatePathFromRoot) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.b"], collator));
- Document doc(fromjson("{c: 5}"));
+ mutablebson::Document doc(fromjson("{c: 5}"));
setPathToCreate("a.b");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()));
@@ -134,7 +133,7 @@ TEST_F(SetNodeTest, ApplyPositional) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.$"], collator));
- Document doc(fromjson("{a: [0, 1, 2]}"));
+ mutablebson::Document doc(fromjson("{a: [0, 1, 2]}"));
setPathTaken("a.1");
setMatchedField("1");
addIndexedPath("a");
@@ -152,7 +151,7 @@ TEST_F(SetNodeTest, ApplyNonViablePathToCreate) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.b"], collator));
- Document doc(fromjson("{a: 5}"));
+ mutablebson::Document doc(fromjson("{a: 5}"));
setPathToCreate("b");
setPathTaken("a");
addIndexedPath("a");
@@ -168,7 +167,7 @@ TEST_F(SetNodeTest, ApplyNonViablePathToCreateFromReplicationIsNoOp) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.b"], collator));
- Document doc(fromjson("{a: 5}"));
+ mutablebson::Document doc(fromjson("{a: 5}"));
setPathToCreate("b");
setPathTaken("a");
addIndexedPath("a");
@@ -187,7 +186,7 @@ TEST_F(SetNodeTest, ApplyNoIndexDataNoLogBuilder) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a"], collator));
- Document doc(fromjson("{a: 5}"));
+ mutablebson::Document doc(fromjson("{a: 5}"));
setPathTaken("a");
setLogBuilderToNull();
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -203,7 +202,7 @@ TEST_F(SetNodeTest, ApplyDoesNotAffectIndexes) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a"], collator));
- Document doc(fromjson("{a: 5}"));
+ mutablebson::Document doc(fromjson("{a: 5}"));
setPathTaken("a");
addIndexedPath("b");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -219,7 +218,7 @@ TEST_F(SetNodeTest, TypeChangeIsNotANoop) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a"], collator));
- Document doc(fromjson("{a: NumberInt(2)}"));
+ mutablebson::Document doc(fromjson("{a: NumberInt(2)}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -236,7 +235,7 @@ TEST_F(SetNodeTest, IdentityOpOnDeserializedIsNotANoOp) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a"], collator));
- Document doc(fromjson("{a: { b: NumberInt(0)}}"));
+ mutablebson::Document doc(fromjson("{a: { b: NumberInt(0)}}"));
// Apply a mutation to the document that will make it non-serialized.
doc.root()["a"]["b"].setValueInt(2).transitional_ignore();
@@ -255,7 +254,7 @@ TEST_F(SetNodeTest, ApplyEmptyDocument) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a"], collator));
- Document doc(fromjson("{}"));
+ mutablebson::Document doc(fromjson("{}"));
setPathToCreate("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()));
@@ -271,7 +270,7 @@ TEST_F(SetNodeTest, ApplyInPlace) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a"], collator));
- Document doc(fromjson("{a: 1}"));
+ mutablebson::Document doc(fromjson("{a: 1}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -287,7 +286,7 @@ TEST_F(SetNodeTest, ApplyOverridePath) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a"], collator));
- Document doc(fromjson("{a: {b: 1}}"));
+ mutablebson::Document doc(fromjson("{a: {b: 1}}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -303,7 +302,7 @@ TEST_F(SetNodeTest, ApplyChangeType) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a"], collator));
- Document doc(fromjson("{a: 'str'}"));
+ mutablebson::Document doc(fromjson("{a: 'str'}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -319,7 +318,7 @@ TEST_F(SetNodeTest, ApplyNewPath) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a"], collator));
- Document doc(fromjson("{b: 1}"));
+ mutablebson::Document doc(fromjson("{b: 1}"));
setPathToCreate("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()));
@@ -335,7 +334,7 @@ TEST_F(SetNodeTest, ApplyLog) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a"], collator));
- Document doc(fromjson("{a: 1}"));
+ mutablebson::Document doc(fromjson("{a: 1}"));
setPathTaken("a");
node.apply(getApplyParams(doc.root()["a"]));
ASSERT_EQUALS(fromjson("{a: 2}"), doc);
@@ -350,7 +349,7 @@ TEST_F(SetNodeTest, ApplyNoOpDottedPath) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.b"], collator));
- Document doc(fromjson("{a: {b: 2}}"));
+ mutablebson::Document doc(fromjson("{a: {b: 2}}"));
setPathTaken("a.b");
addIndexedPath("a.b");
auto result = node.apply(getApplyParams(doc.root()["a"]["b"]));
@@ -366,7 +365,7 @@ TEST_F(SetNodeTest, TypeChangeOnDottedPathIsNotANoOp) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.b"], collator));
- Document doc(fromjson("{a: {b: NumberLong(2)}}"));
+ mutablebson::Document doc(fromjson("{a: {b: NumberLong(2)}}"));
setPathTaken("a.b");
addIndexedPath("a.b");
auto result = node.apply(getApplyParams(doc.root()["a"]["b"]));
@@ -382,7 +381,7 @@ TEST_F(SetNodeTest, ApplyPathNotViable) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.b"], collator));
- Document doc(fromjson("{a:1}"));
+ mutablebson::Document doc(fromjson("{a:1}"));
setPathToCreate("b");
setPathTaken("a");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root()["a"])),
@@ -397,7 +396,7 @@ TEST_F(SetNodeTest, ApplyPathNotViableArrray) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.b"], collator));
- Document doc(fromjson("{a:[{b:1}]}"));
+ mutablebson::Document doc(fromjson("{a:[{b:1}]}"));
setPathToCreate("b");
setPathTaken("a");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root()["a"])),
@@ -412,7 +411,7 @@ TEST_F(SetNodeTest, ApplyInPlaceDottedPath) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.b"], collator));
- Document doc(fromjson("{a: {b: 1}}"));
+ mutablebson::Document doc(fromjson("{a: {b: 1}}"));
setPathTaken("a.b");
addIndexedPath("a.b");
auto result = node.apply(getApplyParams(doc.root()["a"]["b"]));
@@ -428,7 +427,7 @@ TEST_F(SetNodeTest, ApplyChangeTypeDottedPath) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.b"], collator));
- Document doc(fromjson("{a: {b: 'str'}}"));
+ mutablebson::Document doc(fromjson("{a: {b: 'str'}}"));
setPathTaken("a.b");
addIndexedPath("a.b");
auto result = node.apply(getApplyParams(doc.root()["a"]["b"]));
@@ -444,7 +443,7 @@ TEST_F(SetNodeTest, ApplyChangePath) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.b"], collator));
- Document doc(fromjson("{a: {b: {c: 1}}}"));
+ mutablebson::Document doc(fromjson("{a: {b: {c: 1}}}"));
setPathTaken("a.b");
addIndexedPath("a.b");
auto result = node.apply(getApplyParams(doc.root()["a"]["b"]));
@@ -460,7 +459,7 @@ TEST_F(SetNodeTest, ApplyExtendPath) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.b"], collator));
- Document doc(fromjson("{a: {c: 1}}"));
+ mutablebson::Document doc(fromjson("{a: {c: 1}}"));
setPathToCreate("b");
setPathTaken("a");
addIndexedPath("a.b");
@@ -477,7 +476,7 @@ TEST_F(SetNodeTest, ApplyNewDottedPath) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.b"], collator));
- Document doc(fromjson("{c: 1}"));
+ mutablebson::Document doc(fromjson("{c: 1}"));
setPathToCreate("a.b");
addIndexedPath("a.b");
auto result = node.apply(getApplyParams(doc.root()));
@@ -493,7 +492,7 @@ TEST_F(SetNodeTest, ApplyEmptyDoc) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.b"], collator));
- Document doc(fromjson("{}"));
+ mutablebson::Document doc(fromjson("{}"));
setPathToCreate("a.b");
addIndexedPath("a.b");
auto result = node.apply(getApplyParams(doc.root()));
@@ -509,7 +508,7 @@ TEST_F(SetNodeTest, ApplyFieldWithDot) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.b"], collator));
- Document doc(fromjson("{'a.b':4}"));
+ mutablebson::Document doc(fromjson("{'a.b':4}"));
setPathToCreate("a.b");
addIndexedPath("a.b");
auto result = node.apply(getApplyParams(doc.root()));
@@ -525,7 +524,7 @@ TEST_F(SetNodeTest, ApplyNoOpArrayIndex) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.2.b"], collator));
- Document doc(fromjson("{a: [{b: 0},{b: 1},{b: 2}]}"));
+ mutablebson::Document doc(fromjson("{a: [{b: 0},{b: 1},{b: 2}]}"));
setPathTaken("a.2.b");
addIndexedPath("a.2.b");
auto result = node.apply(getApplyParams(doc.root()["a"]["2"]["b"]));
@@ -541,7 +540,7 @@ TEST_F(SetNodeTest, TypeChangeInArrayIsNotANoOp) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.2.b"], collator));
- Document doc(fromjson("{a: [{b: 0},{b: 1},{b: 2.0}]}"));
+ mutablebson::Document doc(fromjson("{a: [{b: 0},{b: 1},{b: 2.0}]}"));
setPathTaken("a.2.b");
addIndexedPath("a.2.b");
auto result = node.apply(getApplyParams(doc.root()["a"]["2"]["b"]));
@@ -557,7 +556,7 @@ TEST_F(SetNodeTest, ApplyNonViablePath) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.2.b"], collator));
- Document doc(fromjson("{a: 0}"));
+ mutablebson::Document doc(fromjson("{a: 0}"));
setPathToCreate("2.b");
setPathTaken("a");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root()["a"])),
@@ -572,7 +571,7 @@ TEST_F(SetNodeTest, ApplyInPlaceArrayIndex) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.2.b"], collator));
- Document doc(fromjson("{a: [{b: 0},{b: 1},{b: 1}]}"));
+ mutablebson::Document doc(fromjson("{a: [{b: 0},{b: 1},{b: 1}]}"));
setPathTaken("a.2.b");
addIndexedPath("a.2.b");
auto result = node.apply(getApplyParams(doc.root()["a"]["2"]["b"]));
@@ -588,7 +587,7 @@ TEST_F(SetNodeTest, ApplyNormalArray) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.2.b"], collator));
- Document doc(fromjson("{a: [{b: 0},{b: 1}]}"));
+ mutablebson::Document doc(fromjson("{a: [{b: 0},{b: 1}]}"));
setPathToCreate("2.b");
setPathTaken("a");
addIndexedPath("a.2.b");
@@ -605,7 +604,7 @@ TEST_F(SetNodeTest, ApplyPaddingArray) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.2.b"], collator));
- Document doc(fromjson("{a: [{b: 0}]}"));
+ mutablebson::Document doc(fromjson("{a: [{b: 0}]}"));
setPathToCreate("2.b");
setPathTaken("a");
addIndexedPath("a.2.b");
@@ -622,7 +621,7 @@ TEST_F(SetNodeTest, ApplyNumericObject) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.2.b"], collator));
- Document doc(fromjson("{a: {b: 0}}"));
+ mutablebson::Document doc(fromjson("{a: {b: 0}}"));
setPathToCreate("2.b");
setPathTaken("a");
addIndexedPath("a.2.b");
@@ -639,7 +638,7 @@ TEST_F(SetNodeTest, ApplyNumericField) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.2.b"], collator));
- Document doc(fromjson("{a: {'2': {b: 1}}}"));
+ mutablebson::Document doc(fromjson("{a: {'2': {b: 1}}}"));
setPathTaken("a.2.b");
addIndexedPath("a.2.b");
auto result = node.apply(getApplyParams(doc.root()["a"]["2"]["b"]));
@@ -655,7 +654,7 @@ TEST_F(SetNodeTest, ApplyExtendNumericField) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.2.b"], collator));
- Document doc(fromjson("{a: {'2': {c: 1}}}"));
+ mutablebson::Document doc(fromjson("{a: {'2': {c: 1}}}"));
setPathToCreate("b");
setPathTaken("a.2");
addIndexedPath("a.2.b");
@@ -672,7 +671,7 @@ TEST_F(SetNodeTest, ApplyEmptyObject) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.2.b"], collator));
- Document doc(fromjson("{a: {}}"));
+ mutablebson::Document doc(fromjson("{a: {}}"));
setPathToCreate("2.b");
setPathTaken("a");
addIndexedPath("a.2.b");
@@ -689,7 +688,7 @@ TEST_F(SetNodeTest, ApplyEmptyArray) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.2.b"], collator));
- Document doc(fromjson("{a: []}"));
+ mutablebson::Document doc(fromjson("{a: []}"));
setPathToCreate("2.b");
setPathTaken("a");
addIndexedPath("a.2.b");
@@ -706,7 +705,7 @@ TEST_F(SetNodeTest, ApplyLogDottedPath) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.2.b"], collator));
- Document doc(fromjson("{a: [{b:0}, {b:1}]}"));
+ mutablebson::Document doc(fromjson("{a: [{b:0}, {b:1}]}"));
setPathToCreate("2.b");
setPathTaken("a");
node.apply(getApplyParams(doc.root()["a"]));
@@ -722,7 +721,7 @@ TEST_F(SetNodeTest, LogEmptyArray) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.2.b"], collator));
- Document doc(fromjson("{a: []}"));
+ mutablebson::Document doc(fromjson("{a: []}"));
setPathToCreate("2.b");
setPathTaken("a");
node.apply(getApplyParams(doc.root()["a"]));
@@ -738,7 +737,7 @@ TEST_F(SetNodeTest, LogEmptyObject) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.2.b"], collator));
- Document doc(fromjson("{a: {}}"));
+ mutablebson::Document doc(fromjson("{a: {}}"));
setPathToCreate("2.b");
setPathTaken("a");
node.apply(getApplyParams(doc.root()["a"]));
@@ -754,7 +753,7 @@ TEST_F(SetNodeTest, ApplyNoOpComplex) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.1.b"], collator));
- Document doc(fromjson("{a: [{b: {c: 0, d: 0}}, {b: {c: 1, d: 1}}]}}"));
+ mutablebson::Document doc(fromjson("{a: [{b: {c: 0, d: 0}}, {b: {c: 1, d: 1}}]}}"));
setPathTaken("a.1.b");
addIndexedPath("a.1.b");
auto result = node.apply(getApplyParams(doc.root()["a"]["1"]["b"]));
@@ -770,7 +769,7 @@ TEST_F(SetNodeTest, ApplySameStructure) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.1.b"], collator));
- Document doc(fromjson("{a: [{b: {c: 0, d: 0}}, {b: {c: 1, xxx: 1}}]}}"));
+ mutablebson::Document doc(fromjson("{a: [{b: {c: 0, d: 0}}, {b: {c: 1, xxx: 1}}]}}"));
setPathTaken("a.1.b");
addIndexedPath("a.1.b");
auto result = node.apply(getApplyParams(doc.root()["a"]["1"]["b"]));
@@ -786,7 +785,7 @@ TEST_F(SetNodeTest, NonViablePathWithoutRepl) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.1.b"], collator));
- Document doc(fromjson("{a: 1}"));
+ mutablebson::Document doc(fromjson("{a: 1}"));
setPathToCreate("1.b");
setPathTaken("a");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root()["a"])),
@@ -801,7 +800,7 @@ TEST_F(SetNodeTest, SingleFieldFromReplication) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.1.b"], collator));
- Document doc(fromjson("{_id:1, a: 1}"));
+ mutablebson::Document doc(fromjson("{_id:1, a: 1}"));
setPathToCreate("1.b");
setPathTaken("a");
addIndexedPath("a.1.b");
@@ -819,7 +818,7 @@ TEST_F(SetNodeTest, SingleFieldNoIdFromReplication) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.1.b"], collator));
- Document doc(fromjson("{a: 1}"));
+ mutablebson::Document doc(fromjson("{a: 1}"));
setPathToCreate("1.b");
setPathTaken("a");
addIndexedPath("a.1.b");
@@ -837,7 +836,7 @@ TEST_F(SetNodeTest, NestedFieldFromReplication) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.a.1.b"], collator));
- Document doc(fromjson("{_id:1, a: {a: 1}}"));
+ mutablebson::Document doc(fromjson("{_id:1, a: {a: 1}}"));
setPathToCreate("1.b");
setPathTaken("a.a");
addIndexedPath("a.a.1.b");
@@ -855,7 +854,7 @@ TEST_F(SetNodeTest, DoubleNestedFieldFromReplication) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.b.c.d"], collator));
- Document doc(fromjson("{_id:1, a: {b: {c: 1}}}"));
+ mutablebson::Document doc(fromjson("{_id:1, a: {b: {c: 1}}}"));
setPathToCreate("d");
setPathTaken("a.b.c");
addIndexedPath("a.b.c.d");
@@ -873,7 +872,7 @@ TEST_F(SetNodeTest, NestedFieldNoIdFromReplication) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.a.1.b"], collator));
- Document doc(fromjson("{a: {a: 1}}"));
+ mutablebson::Document doc(fromjson("{a: {a: 1}}"));
setPathToCreate("1.b");
setPathTaken("a.a");
addIndexedPath("a.a.1.b");
@@ -891,7 +890,7 @@ TEST_F(SetNodeTest, ReplayArrayFieldNotAppendedIntermediateFromReplication) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.0.b"], collator));
- Document doc(fromjson("{_id: 0, a: [1, {b: [1]}]}"));
+ mutablebson::Document doc(fromjson("{_id: 0, a: [1, {b: [1]}]}"));
setPathToCreate("b");
setPathTaken("a.0");
addIndexedPath("a.1.b");
@@ -909,7 +908,7 @@ TEST_F(SetNodeTest, Set6) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["r.a"], collator));
- Document doc(fromjson("{_id: 1, r: {a:1, b:2}}"));
+ mutablebson::Document doc(fromjson("{_id: 1, r: {a:1, b:2}}"));
setPathTaken("r.a");
addIndexedPath("r.a");
auto result = node.apply(getApplyParams(doc.root()["r"]["a"]));
@@ -927,7 +926,7 @@ TEST_F(SetNodeTest, Set6FromRepl) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["r.a"], collator));
- Document doc(fromjson("{_id: 1, r: {a:1, b:2}}"));
+ mutablebson::Document doc(fromjson("{_id: 1, r: {a:1, b:2}}"));
setPathTaken("r.a");
addIndexedPath("r.a");
setFromReplication(true);
@@ -949,7 +948,7 @@ TEST_F(SetNodeTest, ApplySetModToEphemeralDocument) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["x"], collator));
- Document doc;
+ mutablebson::Document doc;
Element x = doc.makeElementObject("x");
doc.root().pushBack(x).transitional_ignore();
Element a = doc.makeElementInt("a", 100);
@@ -970,7 +969,7 @@ TEST_F(SetNodeTest, ApplyCannotCreateDollarPrefixedFieldInsideSetElement) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a"], collator));
- Document doc(fromjson("{a: 5}"));
+ mutablebson::Document doc(fromjson("{a: 5}"));
setPathTaken("a");
ASSERT_THROWS_CODE_AND_WHAT(
node.apply(getApplyParams(doc.root()["a"])),
@@ -985,7 +984,7 @@ TEST_F(SetNodeTest, ApplyCannotCreateDollarPrefixedFieldAtStartOfPath) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["$bad.a"], collator));
- Document doc(fromjson("{}"));
+ mutablebson::Document doc(fromjson("{}"));
setPathToCreate("$bad.a");
ASSERT_THROWS_CODE_AND_WHAT(
node.apply(getApplyParams(doc.root())),
@@ -1000,7 +999,7 @@ TEST_F(SetNodeTest, ApplyCannotCreateDollarPrefixedFieldInMiddleOfPath) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.$bad.b"], collator));
- Document doc(fromjson("{}"));
+ mutablebson::Document doc(fromjson("{}"));
setPathToCreate("a.$bad.b");
ASSERT_THROWS_CODE_AND_WHAT(
node.apply(getApplyParams(doc.root())),
@@ -1015,7 +1014,7 @@ TEST_F(SetNodeTest, ApplyCannotCreateDollarPrefixedFieldAtEndOfPath) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.$bad"], collator));
- Document doc(fromjson("{}"));
+ mutablebson::Document doc(fromjson("{}"));
setPathToCreate("a.$bad");
ASSERT_THROWS_CODE_AND_WHAT(
node.apply(getApplyParams(doc.root())),
@@ -1030,7 +1029,7 @@ TEST_F(SetNodeTest, ApplyCanCreateDollarPrefixedFieldNameWhenValidateForStorageI
SetNode node;
ASSERT_OK(node.init(update["$set"]["$bad"], collator));
- Document doc(fromjson("{}"));
+ mutablebson::Document doc(fromjson("{}"));
setPathToCreate("$bad");
addIndexedPath("$bad");
setValidateForStorage(false);
@@ -1049,7 +1048,7 @@ TEST_F(SetNodeTest, ApplyCannotOverwriteImmutablePath) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.b"], collator));
- Document doc(fromjson("{a: {b: 2}}"));
+ mutablebson::Document doc(fromjson("{a: {b: 2}}"));
setPathTaken("a.b");
addImmutablePath("a.b");
ASSERT_THROWS_CODE_AND_WHAT(
@@ -1065,7 +1064,7 @@ TEST_F(SetNodeTest, ApplyCanPerformNoopOnImmutablePath) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.b"], collator));
- Document doc(fromjson("{a: {b: 2}}"));
+ mutablebson::Document doc(fromjson("{a: {b: 2}}"));
setPathTaken("a.b");
addImmutablePath("a.b");
addIndexedPath("a");
@@ -1084,7 +1083,7 @@ TEST_F(SetNodeTest, ApplyCannotOverwritePrefixToRemoveImmutablePath) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a"], collator));
- Document doc(fromjson("{a: {b: 2}}"));
+ mutablebson::Document doc(fromjson("{a: {b: 2}}"));
setPathTaken("a");
addImmutablePath("a.b");
ASSERT_THROWS_CODE_AND_WHAT(
@@ -1100,7 +1099,7 @@ TEST_F(SetNodeTest, ApplyCannotOverwritePrefixToModifyImmutablePath) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a"], collator));
- Document doc(fromjson("{a: {b: 2}}"));
+ mutablebson::Document doc(fromjson("{a: {b: 2}}"));
setPathTaken("a");
addImmutablePath("a.b");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root()["a"])),
@@ -1116,7 +1115,7 @@ TEST_F(SetNodeTest, ApplyCanPerformNoopOnPrefixOfImmutablePath) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a"], collator));
- Document doc(fromjson("{a: {b: 2}}"));
+ mutablebson::Document doc(fromjson("{a: {b: 2}}"));
setPathTaken("a");
addImmutablePath("a.b");
addIndexedPath("a");
@@ -1135,7 +1134,7 @@ TEST_F(SetNodeTest, ApplyCanOverwritePrefixToCreateImmutablePath) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a"], collator));
- Document doc(fromjson("{a: 1}"));
+ mutablebson::Document doc(fromjson("{a: 1}"));
setPathTaken("a");
addImmutablePath("a.b");
addIndexedPath("a");
@@ -1154,7 +1153,7 @@ TEST_F(SetNodeTest, ApplyCanOverwritePrefixOfImmutablePathIfNoopOnImmutablePath)
SetNode node;
ASSERT_OK(node.init(update["$set"]["a"], collator));
- Document doc(fromjson("{a: {b: 2}}"));
+ mutablebson::Document doc(fromjson("{a: {b: 2}}"));
setPathTaken("a");
addImmutablePath("a.b");
addIndexedPath("a");
@@ -1173,7 +1172,7 @@ TEST_F(SetNodeTest, ApplyCannotOverwriteSuffixOfImmutablePath) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.b.c"], collator));
- Document doc(fromjson("{a: {b: {c: 2}}}"));
+ mutablebson::Document doc(fromjson("{a: {b: {c: 2}}}"));
setPathTaken("a.b.c");
addImmutablePath("a.b");
ASSERT_THROWS_CODE_AND_WHAT(
@@ -1189,7 +1188,7 @@ TEST_F(SetNodeTest, ApplyCanPerformNoopOnSuffixOfImmutablePath) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.b.c"], collator));
- Document doc(fromjson("{a: {b: {c: 2}}}"));
+ mutablebson::Document doc(fromjson("{a: {b: {c: 2}}}"));
setPathTaken("a.b.c");
addImmutablePath("a.b");
addIndexedPath("a");
@@ -1208,7 +1207,7 @@ TEST_F(SetNodeTest, ApplyCannotCreateFieldAtEndOfImmutablePath) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.b.c"], collator));
- Document doc(fromjson("{a: {b: {}}}"));
+ mutablebson::Document doc(fromjson("{a: {b: {}}}"));
setPathToCreate("c");
setPathTaken("a.b");
addImmutablePath("a.b");
@@ -1225,7 +1224,7 @@ TEST_F(SetNodeTest, ApplyCannotCreateFieldBeyondEndOfImmutablePath) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.b.c"], collator));
- Document doc(fromjson("{a: {b: {}}}"));
+ mutablebson::Document doc(fromjson("{a: {b: {}}}"));
setPathToCreate("c");
setPathTaken("a.b");
addImmutablePath("a");
@@ -1242,7 +1241,7 @@ TEST_F(SetNodeTest, ApplyCanCreateImmutablePath) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a.b"], collator));
- Document doc(fromjson("{a: {}}"));
+ mutablebson::Document doc(fromjson("{a: {}}"));
setPathToCreate("b");
setPathTaken("a");
addImmutablePath("a.b");
@@ -1262,7 +1261,7 @@ TEST_F(SetNodeTest, ApplyCanCreatePrefixOfImmutablePath) {
SetNode node;
ASSERT_OK(node.init(update["$set"]["a"], collator));
- Document doc(fromjson("{}"));
+ mutablebson::Document doc(fromjson("{}"));
setPathToCreate("a");
addImmutablePath("a.b");
addIndexedPath("a");
@@ -1281,7 +1280,7 @@ TEST_F(SetNodeTest, ApplySetOnInsertIsNoopWhenInsertIsFalse) {
SetNode node(UpdateNode::Context::kInsertOnly);
ASSERT_OK(node.init(update["$setOnInsert"]["a"], collator));
- Document doc(fromjson("{}"));
+ mutablebson::Document doc(fromjson("{}"));
setPathToCreate("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()));
@@ -1298,7 +1297,7 @@ TEST_F(SetNodeTest, ApplySetOnInsertIsAppliedWhenInsertIsTrue) {
SetNode node(UpdateNode::Context::kInsertOnly);
ASSERT_OK(node.init(update["$setOnInsert"]["a"], collator));
- Document doc(fromjson("{}"));
+ mutablebson::Document doc(fromjson("{}"));
setPathToCreate("a");
setInsert(true);
addIndexedPath("a");
@@ -1316,7 +1315,7 @@ TEST_F(SetNodeTest, ApplySetOnInsertExistingPath) {
SetNode node(UpdateNode::Context::kInsertOnly);
ASSERT_OK(node.init(update["$setOnInsert"]["a"], collator));
- Document doc(fromjson("{a: 1}"));
+ mutablebson::Document doc(fromjson("{a: 1}"));
setPathTaken("a");
setInsert(true);
addIndexedPath("a");
diff --git a/src/mongo/db/update/unset_node_test.cpp b/src/mongo/db/update/unset_node_test.cpp
index ad8f373e943..94be0fadb2d 100644
--- a/src/mongo/db/update/unset_node_test.cpp
+++ b/src/mongo/db/update/unset_node_test.cpp
@@ -41,7 +41,6 @@ namespace mongo {
namespace {
using UnsetNodeTest = UpdateNodeTest;
-using mongo::mutablebson::Document;
using mongo::mutablebson::Element;
using mongo::mutablebson::countChildren;
@@ -58,7 +57,7 @@ DEATH_TEST_F(UnsetNodeTest, ApplyToRootFails, "Invariant failure parent.ok()") {
UnsetNode node;
ASSERT_OK(node.init(update["$unset"], collator));
- Document doc(fromjson("{a: 5}"));
+ mutablebson::Document doc(fromjson("{a: 5}"));
node.apply(getApplyParams(doc.root()));
}
@@ -76,7 +75,7 @@ TEST_F(UnsetNodeTest, UnsetNoOp) {
UnsetNode node;
ASSERT_OK(node.init(update["$unset"]["a"], collator));
- Document doc(fromjson("{b: 5}"));
+ mutablebson::Document doc(fromjson("{b: 5}"));
setPathToCreate("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()));
@@ -93,7 +92,7 @@ TEST_F(UnsetNodeTest, UnsetNoOpDottedPath) {
UnsetNode node;
ASSERT_OK(node.init(update["$unset"]["a.b"], collator));
- Document doc(fromjson("{a: 5}"));
+ mutablebson::Document doc(fromjson("{a: 5}"));
setPathToCreate("b");
setPathTaken("a");
addIndexedPath("a");
@@ -111,7 +110,7 @@ TEST_F(UnsetNodeTest, UnsetNoOpThroughArray) {
UnsetNode node;
ASSERT_OK(node.init(update["$unset"]["a.b"], collator));
- Document doc(fromjson("{a:[{b:1}]}"));
+ mutablebson::Document doc(fromjson("{a:[{b:1}]}"));
setPathToCreate("b");
setPathTaken("a");
addIndexedPath("a");
@@ -129,7 +128,7 @@ TEST_F(UnsetNodeTest, UnsetNoOpEmptyDoc) {
UnsetNode node;
ASSERT_OK(node.init(update["$unset"]["a"], collator));
- Document doc(fromjson("{}"));
+ mutablebson::Document doc(fromjson("{}"));
setPathToCreate("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()));
@@ -146,7 +145,7 @@ TEST_F(UnsetNodeTest, UnsetTopLevelPath) {
UnsetNode node;
ASSERT_OK(node.init(update["$unset"]["a"], collator));
- Document doc(fromjson("{a: 5}"));
+ mutablebson::Document doc(fromjson("{a: 5}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -163,7 +162,7 @@ TEST_F(UnsetNodeTest, UnsetNestedPath) {
UnsetNode node;
ASSERT_OK(node.init(update["$unset"]["a.b.c"], collator));
- Document doc(fromjson("{a: {b: {c: 6}}}}"));
+ mutablebson::Document doc(fromjson("{a: {b: {c: 6}}}}"));
setPathTaken("a.b.c");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]["b"]["c"]));
@@ -180,7 +179,7 @@ TEST_F(UnsetNodeTest, UnsetObject) {
UnsetNode node;
ASSERT_OK(node.init(update["$unset"]["a.b"], collator));
- Document doc(fromjson("{a: {b: {c: 6}}}}"));
+ mutablebson::Document doc(fromjson("{a: {b: {c: 6}}}}"));
setPathTaken("a.b");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]["b"]));
@@ -197,7 +196,7 @@ TEST_F(UnsetNodeTest, UnsetArrayElement) {
UnsetNode node;
ASSERT_OK(node.init(update["$unset"]["a.0"], collator));
- Document doc(fromjson("{a:[1], b:1}"));
+ mutablebson::Document doc(fromjson("{a:[1], b:1}"));
setPathTaken("a.0");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]["0"]));
@@ -214,7 +213,7 @@ TEST_F(UnsetNodeTest, UnsetPositional) {
UnsetNode node;
ASSERT_OK(node.init(update["$unset"]["a.$"], collator));
- Document doc(fromjson("{a: [0, 1, 2]}"));
+ mutablebson::Document doc(fromjson("{a: [0, 1, 2]}"));
setPathTaken("a.1");
setMatchedField("1");
addIndexedPath("a");
@@ -232,7 +231,7 @@ TEST_F(UnsetNodeTest, UnsetEntireArray) {
UnsetNode node;
ASSERT_OK(node.init(update["$unset"]["a"], collator));
- Document doc(fromjson("{a: [0, 1, 2]}"));
+ mutablebson::Document doc(fromjson("{a: [0, 1, 2]}"));
setPathTaken("a");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -249,7 +248,7 @@ TEST_F(UnsetNodeTest, UnsetFromObjectInArray) {
UnsetNode node;
ASSERT_OK(node.init(update["$unset"]["a.0.b"], collator));
- Document doc(fromjson("{a: [{b: 1}]}"));
+ mutablebson::Document doc(fromjson("{a: [{b: 1}]}"));
setPathTaken("a.0.b");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]["0"]["b"]));
@@ -266,7 +265,7 @@ TEST_F(UnsetNodeTest, CanUnsetInvalidField) {
UnsetNode node;
ASSERT_OK(node.init(update["$unset"]["a.$.$b"], collator));
- Document doc(fromjson("{b: 1, a: [{$b: 1}]}"));
+ mutablebson::Document doc(fromjson("{b: 1, a: [{$b: 1}]}"));
setPathTaken("a.0.$b");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]["0"]["$b"]));
@@ -283,7 +282,7 @@ TEST_F(UnsetNodeTest, ApplyNoIndexDataNoLogBuilder) {
UnsetNode node;
ASSERT_OK(node.init(update["$unset"]["a"], collator));
- Document doc(fromjson("{a: 5}"));
+ mutablebson::Document doc(fromjson("{a: 5}"));
setPathTaken("a");
setLogBuilderToNull();
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -299,7 +298,7 @@ TEST_F(UnsetNodeTest, ApplyDoesNotAffectIndexes) {
UnsetNode node;
ASSERT_OK(node.init(update["$unset"]["a"], collator));
- Document doc(fromjson("{a: 5}"));
+ mutablebson::Document doc(fromjson("{a: 5}"));
setPathTaken("a");
addIndexedPath("b");
auto result = node.apply(getApplyParams(doc.root()["a"]));
@@ -316,7 +315,7 @@ TEST_F(UnsetNodeTest, ApplyFieldWithDot) {
UnsetNode node;
ASSERT_OK(node.init(update["$unset"]["a.b"], collator));
- Document doc(fromjson("{'a.b':4, a: {b: 2}}"));
+ mutablebson::Document doc(fromjson("{'a.b':4, a: {b: 2}}"));
setPathTaken("a.b");
addIndexedPath("a");
auto result = node.apply(getApplyParams(doc.root()["a"]["b"]));
@@ -333,7 +332,7 @@ TEST_F(UnsetNodeTest, ApplyCannotRemoveRequiredPartOfDBRef) {
UnsetNode node;
ASSERT_OK(node.init(update["$unset"]["a.$id"], collator));
- Document doc(fromjson("{a: {$ref: 'c', $id: 0}}"));
+ mutablebson::Document doc(fromjson("{a: {$ref: 'c', $id: 0}}"));
setPathTaken("a.$id");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root()["a"]["$id"])),
UserException,
@@ -347,7 +346,7 @@ TEST_F(UnsetNodeTest, ApplyCanRemoveRequiredPartOfDBRefIfValidateForStorageIsFal
UnsetNode node;
ASSERT_OK(node.init(update["$unset"]["a.$id"], collator));
- Document doc(fromjson("{a: {$ref: 'c', $id: 0}}"));
+ mutablebson::Document doc(fromjson("{a: {$ref: 'c', $id: 0}}"));
setPathTaken("a.$id");
addIndexedPath("a");
setValidateForStorage(false);
@@ -367,7 +366,7 @@ TEST_F(UnsetNodeTest, ApplyCannotRemoveImmutablePath) {
UnsetNode node;
ASSERT_OK(node.init(update["$unset"]["a.b"], collator));
- Document doc(fromjson("{a: {b: 1}}"));
+ mutablebson::Document doc(fromjson("{a: {b: 1}}"));
setPathTaken("a.b");
addImmutablePath("a.b");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root()["a"]["b"])),
@@ -382,7 +381,7 @@ TEST_F(UnsetNodeTest, ApplyCannotRemovePrefixOfImmutablePath) {
UnsetNode node;
ASSERT_OK(node.init(update["$unset"]["a"], collator));
- Document doc(fromjson("{a: {b: 1}}"));
+ mutablebson::Document doc(fromjson("{a: {b: 1}}"));
setPathTaken("a");
addImmutablePath("a.b");
ASSERT_THROWS_CODE_AND_WHAT(node.apply(getApplyParams(doc.root()["a"])),
@@ -397,7 +396,7 @@ TEST_F(UnsetNodeTest, ApplyCannotRemoveSuffixOfImmutablePath) {
UnsetNode node;
ASSERT_OK(node.init(update["$unset"]["a.b.c"], collator));
- Document doc(fromjson("{a: {b: {c: 1}}}"));
+ mutablebson::Document doc(fromjson("{a: {b: {c: 1}}}"));
setPathTaken("a.b.c");
addImmutablePath("a.b");
ASSERT_THROWS_CODE_AND_WHAT(
@@ -413,7 +412,7 @@ TEST_F(UnsetNodeTest, ApplyCanRemoveImmutablePathIfNoop) {
UnsetNode node;
ASSERT_OK(node.init(update["$unset"]["a.b.c"], collator));
- Document doc(fromjson("{a: {b: 1}}"));
+ mutablebson::Document doc(fromjson("{a: {b: 1}}"));
setPathToCreate("c");
setPathTaken("a.b");
addImmutablePath("a.b");
diff --git a/src/mongo/db/update/update_array_node_test.cpp b/src/mongo/db/update/update_array_node_test.cpp
index 60c5bfb4448..42087846813 100644
--- a/src/mongo/db/update/update_array_node_test.cpp
+++ b/src/mongo/db/update/update_array_node_test.cpp
@@ -42,7 +42,6 @@ namespace mongo {
namespace {
using UpdateArrayNodeTest = UpdateNodeTest;
-using mongo::mutablebson::Document;
using mongo::mutablebson::Element;
TEST_F(UpdateArrayNodeTest, ApplyCreatePathFails) {
@@ -60,7 +59,7 @@ TEST_F(UpdateArrayNodeTest, ApplyCreatePathFails) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{a: {}}"));
+ mutablebson::Document doc(fromjson("{a: {}}"));
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(
root.apply(getApplyParams(doc.root())),
@@ -84,7 +83,7 @@ TEST_F(UpdateArrayNodeTest, ApplyToNonArrayFails) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{a: {}}"));
+ mutablebson::Document doc(fromjson("{a: {}}"));
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(root.apply(getApplyParams(doc.root())),
UserException,
@@ -107,7 +106,7 @@ TEST_F(UpdateArrayNodeTest, UpdateIsAppliedToAllMatchingElements) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{a: [0, 1, 0]}"));
+ mutablebson::Document doc(fromjson("{a: [0, 1, 0]}"));
addIndexedPath("a");
auto result = root.apply(getApplyParams(doc.root()));
ASSERT_TRUE(result.indexesAffected);
@@ -134,7 +133,7 @@ DEATH_TEST_F(UpdateArrayNodeTest,
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{a: [{c: 0}, {c: 0}, {c: 1}]}"));
+ mutablebson::Document doc(fromjson("{a: [{c: 0}, {c: 0}, {c: 1}]}"));
doc.root()["a"]["1"]["c"].setValueInt(1).transitional_ignore();
doc.root()["a"]["2"]["c"].setValueInt(0).transitional_ignore();
addIndexedPath("a");
@@ -154,7 +153,7 @@ TEST_F(UpdateArrayNodeTest, UpdateForEmptyIdentifierIsAppliedToAllArrayElements)
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{a: [0, 0, 0]}"));
+ mutablebson::Document doc(fromjson("{a: [0, 0, 0]}"));
addIndexedPath("a");
auto result = root.apply(getApplyParams(doc.root()));
ASSERT_TRUE(result.indexesAffected);
@@ -195,7 +194,7 @@ TEST_F(UpdateArrayNodeTest, ApplyMultipleUpdatesToArrayElement) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{a: [{b: 0, c: 0, d: 0}]}"));
+ mutablebson::Document doc(fromjson("{a: [{b: 0, c: 0, d: 0}]}"));
addIndexedPath("a");
auto result = root.apply(getApplyParams(doc.root()));
ASSERT_TRUE(result.indexesAffected);
@@ -228,7 +227,7 @@ TEST_F(UpdateArrayNodeTest, ApplyMultipleUpdatesToArrayElementsUsingMergedChildr
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{a: [{b: 0, c: 0}, {b: 0, c: 0}]}"));
+ mutablebson::Document doc(fromjson("{a: [{b: 0, c: 0}, {b: 0, c: 0}]}"));
addIndexedPath("a");
auto result = root.apply(getApplyParams(doc.root()));
ASSERT_TRUE(result.indexesAffected);
@@ -269,7 +268,7 @@ TEST_F(UpdateArrayNodeTest, ApplyMultipleUpdatesToArrayElementsWithoutMergedChil
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{a: [{b: 0, c: 0, d: 1}, {b: 1, c: 0, d: 0}]}"));
+ mutablebson::Document doc(fromjson("{a: [{b: 0, c: 0, d: 1}, {b: 1, c: 0, d: 0}]}"));
addIndexedPath("a");
auto result = root.apply(getApplyParams(doc.root()));
ASSERT_TRUE(result.indexesAffected);
@@ -298,7 +297,7 @@ TEST_F(UpdateArrayNodeTest, ApplyMultipleUpdatesToArrayElementWithEmptyIdentifie
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{a: [{b: 0, c: 0}]}"));
+ mutablebson::Document doc(fromjson("{a: [{b: 0, c: 0}]}"));
addIndexedPath("a");
auto result = root.apply(getApplyParams(doc.root()));
ASSERT_TRUE(result.indexesAffected);
@@ -335,7 +334,7 @@ TEST_F(UpdateArrayNodeTest, ApplyNestedArrayUpdates) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{a: [{x: 0, b: [{c: 0, d: 0}]}]}"));
+ mutablebson::Document doc(fromjson("{a: [{x: 0, b: [{c: 0, d: 0}]}]}"));
addIndexedPath("a");
auto result = root.apply(getApplyParams(doc.root()));
ASSERT_TRUE(result.indexesAffected);
@@ -368,7 +367,7 @@ TEST_F(UpdateArrayNodeTest, ApplyUpdatesWithMergeConflictToArrayElementFails) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{a: [0]}"));
+ mutablebson::Document doc(fromjson("{a: [0]}"));
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(root.apply(getApplyParams(doc.root())),
UserException,
@@ -399,7 +398,7 @@ TEST_F(UpdateArrayNodeTest, ApplyUpdatesWithEmptyIdentifiersWithMergeConflictToA
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{a: [{b: [0]}]}"));
+ mutablebson::Document doc(fromjson("{a: [{b: [0]}]}"));
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(root.apply(getApplyParams(doc.root())),
UserException,
@@ -434,7 +433,7 @@ TEST_F(UpdateArrayNodeTest, ApplyNestedArrayUpdatesWithMergeConflictFails) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{a: [{b: [0], c: 0}]}"));
+ mutablebson::Document doc(fromjson("{a: [{b: [0], c: 0}]}"));
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(root.apply(getApplyParams(doc.root())),
UserException,
@@ -457,7 +456,7 @@ TEST_F(UpdateArrayNodeTest, NoArrayElementsMatch) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{a: [2, 2, 2]}"));
+ mutablebson::Document doc(fromjson("{a: [2, 2, 2]}"));
addIndexedPath("a");
auto result = root.apply(getApplyParams(doc.root()));
ASSERT_FALSE(result.indexesAffected);
@@ -482,7 +481,7 @@ TEST_F(UpdateArrayNodeTest, UpdatesToAllArrayElementsAreNoops) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{a: [1, 1, 1]}"));
+ mutablebson::Document doc(fromjson("{a: [1, 1, 1]}"));
addIndexedPath("a");
auto result = root.apply(getApplyParams(doc.root()));
ASSERT_FALSE(result.indexesAffected);
@@ -507,7 +506,7 @@ TEST_F(UpdateArrayNodeTest, NoArrayElementAffectsIndexes) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{a: [{c: 0}, {c: 0}, {c: 0}]}"));
+ mutablebson::Document doc(fromjson("{a: [{c: 0}, {c: 0}, {c: 0}]}"));
addIndexedPath("a.c");
auto result = root.apply(getApplyParams(doc.root()));
ASSERT_FALSE(result.indexesAffected);
@@ -532,7 +531,7 @@ TEST_F(UpdateArrayNodeTest, WhenOneElementIsMatchedLogElementUpdateDirectly) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{a: [{c: 1}, {c: 0}, {c: 1}]}"));
+ mutablebson::Document doc(fromjson("{a: [{c: 1}, {c: 0}, {c: 1}]}"));
addIndexedPath("a");
auto result = root.apply(getApplyParams(doc.root()));
ASSERT_TRUE(result.indexesAffected);
@@ -557,7 +556,7 @@ TEST_F(UpdateArrayNodeTest, WhenOneElementIsModifiedLogElement) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{a: [{c: 0, b: 0}, {c: 0}, {c: 1}]}"));
+ mutablebson::Document doc(fromjson("{a: [{c: 0, b: 0}, {c: 0}, {c: 1}]}"));
addIndexedPath("a");
auto result = root.apply(getApplyParams(doc.root()));
ASSERT_TRUE(result.indexesAffected);
@@ -580,7 +579,7 @@ TEST_F(UpdateArrayNodeTest, ArrayUpdateOnEmptyArrayIsANoop) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{a: []}"));
+ mutablebson::Document doc(fromjson("{a: []}"));
addIndexedPath("a");
auto result = root.apply(getApplyParams(doc.root()));
ASSERT_FALSE(result.indexesAffected);
@@ -605,7 +604,7 @@ TEST_F(UpdateArrayNodeTest, ApplyPositionalInsideArrayUpdate) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{a: [{b: [0, 0], c: 0}]}"));
+ mutablebson::Document doc(fromjson("{a: [{b: [0, 0], c: 0}]}"));
addIndexedPath("a");
setMatchedField("1");
auto result = root.apply(getApplyParams(doc.root()));
@@ -631,7 +630,7 @@ TEST_F(UpdateArrayNodeTest, ApplyArrayUpdateFromReplication) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{a: [0]}"));
+ mutablebson::Document doc(fromjson("{a: [0]}"));
addIndexedPath("a");
setFromReplication(true);
auto result = root.apply(getApplyParams(doc.root()));
@@ -657,7 +656,7 @@ TEST_F(UpdateArrayNodeTest, ApplyArrayUpdateNotFromReplication) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{a: [0]}"));
+ mutablebson::Document doc(fromjson("{a: [0]}"));
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(root.apply(getApplyParams(doc.root())),
UserException,
@@ -680,7 +679,7 @@ TEST_F(UpdateArrayNodeTest, ApplyArrayUpdateWithoutLogBuilderOrIndexData) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{a: [0]}"));
+ mutablebson::Document doc(fromjson("{a: [0]}"));
setLogBuilderToNull();
auto result = root.apply(getApplyParams(doc.root()));
ASSERT_FALSE(result.indexesAffected);
diff --git a/src/mongo/db/update/update_driver_test.cpp b/src/mongo/db/update/update_driver_test.cpp
index f37074ce24b..02b6ae0e442 100644
--- a/src/mongo/db/update/update_driver_test.cpp
+++ b/src/mongo/db/update/update_driver_test.cpp
@@ -47,7 +47,6 @@
namespace mongo {
namespace {
-using mongo::mutablebson::Document;
using mongoutils::str::stream;
TEST(Parse, Normal) {
@@ -163,7 +162,7 @@ TEST(Collator, SetCollationUpdatesModifierInterfaces) {
const bool validateForStorage = true;
const FieldRefSet emptyImmutablePaths;
bool modified = false;
- Document doc(fromjson("{a: 'cba'}"));
+ mutablebson::Document doc(fromjson("{a: 'cba'}"));
driver.setCollator(&collator);
driver
.update(StringData(),
@@ -195,7 +194,7 @@ public:
_opCtx = _serviceContext.makeOperationContext();
}
- Document& doc() {
+ mutablebson::Document& doc() {
return _doc;
}
@@ -217,7 +216,7 @@ private:
std::map<StringData, std::unique_ptr<ExpressionWithPlaceholder>> _arrayFilters;
std::unique_ptr<UpdateDriver> _driverOps;
std::unique_ptr<UpdateDriver> _driverRepl;
- Document _doc;
+ mutablebson::Document _doc;
};
// Make name nicer to report
diff --git a/src/mongo/db/update/update_object_node_test.cpp b/src/mongo/db/update/update_object_node_test.cpp
index 018719b827a..6bb3d2c51c8 100644
--- a/src/mongo/db/update/update_object_node_test.cpp
+++ b/src/mongo/db/update/update_object_node_test.cpp
@@ -45,7 +45,6 @@ namespace mongo {
namespace {
using UpdateObjectNodeTest = UpdateNodeTest;
-using mongo::mutablebson::Document;
using mongo::mutablebson::Element;
TEST(UpdateObjectNodeTest, InvalidPathFailsToParse) {
@@ -1729,7 +1728,7 @@ TEST_F(UpdateObjectNodeTest, ApplyCreateField) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{a: 5}"));
+ mutablebson::Document doc(fromjson("{a: 5}"));
addIndexedPath("b");
auto result = root.apply(getApplyParams(doc.root()));
ASSERT_TRUE(result.indexesAffected);
@@ -1752,7 +1751,7 @@ TEST_F(UpdateObjectNodeTest, ApplyExistingField) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{a: 5}"));
+ mutablebson::Document doc(fromjson("{a: 5}"));
addIndexedPath("a");
auto result = root.apply(getApplyParams(doc.root()));
ASSERT_TRUE(result.indexesAffected);
@@ -1793,7 +1792,7 @@ TEST_F(UpdateObjectNodeTest, ApplyExistingAndNonexistingFields) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{a: 0, c: 0}"));
+ mutablebson::Document doc(fromjson("{a: 0, c: 0}"));
addIndexedPath("a");
auto result = root.apply(getApplyParams(doc.root()));
ASSERT_TRUE(result.indexesAffected);
@@ -1834,7 +1833,7 @@ TEST_F(UpdateObjectNodeTest, ApplyExistingNestedPaths) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{a: {b: 5, c: 5}, b: {d: 5, e: 5}}"));
+ mutablebson::Document doc(fromjson("{a: {b: 5, c: 5}, b: {d: 5, e: 5}}"));
addIndexedPath("a");
auto result = root.apply(getApplyParams(doc.root()));
ASSERT_TRUE(result.indexesAffected);
@@ -1876,7 +1875,7 @@ TEST_F(UpdateObjectNodeTest, ApplyCreateNestedPaths) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{z: 0}"));
+ mutablebson::Document doc(fromjson("{z: 0}"));
addIndexedPath("a");
auto result = root.apply(getApplyParams(doc.root()));
ASSERT_TRUE(result.indexesAffected);
@@ -1912,7 +1911,7 @@ TEST_F(UpdateObjectNodeTest, ApplyCreateDeeplyNestedPaths) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{z: 0}"));
+ mutablebson::Document doc(fromjson("{z: 0}"));
addIndexedPath("a");
auto result = root.apply(getApplyParams(doc.root()));
ASSERT_TRUE(result.indexesAffected);
@@ -1960,7 +1959,7 @@ TEST_F(UpdateObjectNodeTest, ChildrenShouldBeAppliedInAlphabeticalOrder) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{z: 0, a: 0}"));
+ mutablebson::Document doc(fromjson("{z: 0, a: 0}"));
addIndexedPath("a");
auto result = root.apply(getApplyParams(doc.root()));
ASSERT_TRUE(result.indexesAffected);
@@ -1989,7 +1988,7 @@ TEST_F(UpdateObjectNodeTest, CollatorShouldNotAffectUpdateOrder) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{}"));
+ mutablebson::Document doc(fromjson("{}"));
addIndexedPath("abc");
auto result = root.apply(getApplyParams(doc.root()));
ASSERT_TRUE(result.indexesAffected);
@@ -2024,7 +2023,7 @@ TEST_F(UpdateObjectNodeTest, ApplyNoop) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{a: 5, b: 6, c: 7}"));
+ mutablebson::Document doc(fromjson("{a: 5, b: 6, c: 7}"));
addIndexedPath("a");
addIndexedPath("b");
addIndexedPath("c");
@@ -2061,7 +2060,7 @@ TEST_F(UpdateObjectNodeTest, ApplySomeChildrenNoops) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{a: 5, b: 0, c: 7}"));
+ mutablebson::Document doc(fromjson("{a: 5, b: 0, c: 7}"));
addIndexedPath("a");
addIndexedPath("b");
addIndexedPath("c");
@@ -2086,7 +2085,7 @@ TEST_F(UpdateObjectNodeTest, ApplyBlockingElement) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{a: 0}"));
+ mutablebson::Document doc(fromjson("{a: 0}"));
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(root.apply(getApplyParams(doc.root())),
UserException,
@@ -2113,7 +2112,7 @@ TEST_F(UpdateObjectNodeTest, ApplyBlockingElementFromReplication) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{a: 0}"));
+ mutablebson::Document doc(fromjson("{a: 0}"));
addIndexedPath("a");
setFromReplication(true);
auto result = root.apply(getApplyParams(doc.root()));
@@ -2137,7 +2136,7 @@ TEST_F(UpdateObjectNodeTest, ApplyPositionalMissingMatchedField) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{}"));
+ mutablebson::Document doc(fromjson("{}"));
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(
root.apply(getApplyParams(doc.root())),
@@ -2165,7 +2164,7 @@ TEST_F(UpdateObjectNodeTest, ApplyMergePositionalChild) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{a: [{b: 0, c: 0}]}"));
+ mutablebson::Document doc(fromjson("{a: [{b: 0, c: 0}]}"));
setMatchedField("0");
addIndexedPath("a");
auto result = root.apply(getApplyParams(doc.root()));
@@ -2207,7 +2206,7 @@ TEST_F(UpdateObjectNodeTest, ApplyOrderMergedPositionalChild) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{}"));
+ mutablebson::Document doc(fromjson("{}"));
setMatchedField("1");
addIndexedPath("a");
auto result = root.apply(getApplyParams(doc.root()));
@@ -2238,7 +2237,7 @@ TEST_F(UpdateObjectNodeTest, ApplyMergeConflictWithPositionalChild) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{}"));
+ mutablebson::Document doc(fromjson("{}"));
setMatchedField("0");
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(root.apply(getApplyParams(doc.root())),
@@ -2272,7 +2271,7 @@ TEST_F(UpdateObjectNodeTest, ApplyDoNotMergePositionalChild) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{}"));
+ mutablebson::Document doc(fromjson("{}"));
setMatchedField("1");
addIndexedPath("a");
auto result = root.apply(getApplyParams(doc.root()));
@@ -2308,7 +2307,7 @@ TEST_F(UpdateObjectNodeTest, ApplyPositionalChildLast) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{}"));
+ mutablebson::Document doc(fromjson("{}"));
setMatchedField("2");
addIndexedPath("a");
auto result = root.apply(getApplyParams(doc.root()));
@@ -2338,7 +2337,7 @@ TEST_F(UpdateObjectNodeTest, ApplyUseStoredMergedPositional) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{a: [{b: 0, c: 0}]}"));
+ mutablebson::Document doc(fromjson("{a: [{b: 0, c: 0}]}"));
setMatchedField("0");
addIndexedPath("a");
auto result = root.apply(getApplyParams(doc.root()));
@@ -2348,7 +2347,7 @@ TEST_F(UpdateObjectNodeTest, ApplyUseStoredMergedPositional) {
ASSERT_TRUE(doc.isInPlaceModeEnabled());
ASSERT_BSONOBJ_EQ(fromjson("{$set: {'a.0.b': 5, 'a.0.c': 6}}"), getLogDoc().getObject());
- Document doc2(fromjson("{a: [{b: 0, c: 0}]}"));
+ mutablebson::Document doc2(fromjson("{a: [{b: 0, c: 0}]}"));
resetApplyParams();
setMatchedField("0");
addIndexedPath("a");
@@ -2385,7 +2384,7 @@ TEST_F(UpdateObjectNodeTest, ApplyDoNotUseStoredMergedPositional) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{a: [{b: 0, c: 0}, {c: 0, d: 0}]}"));
+ mutablebson::Document doc(fromjson("{a: [{b: 0, c: 0}, {c: 0, d: 0}]}"));
setMatchedField("0");
addIndexedPath("a");
auto result = root.apply(getApplyParams(doc.root()));
@@ -2396,7 +2395,7 @@ TEST_F(UpdateObjectNodeTest, ApplyDoNotUseStoredMergedPositional) {
ASSERT_BSONOBJ_EQ(fromjson("{$set: {'a.0.b': 5, 'a.0.c': 6, 'a.1.d': 7}}"),
getLogDoc().getObject());
- Document doc2(fromjson("{a: [{b: 0, c: 0}, {c: 0, d: 0}]}"));
+ mutablebson::Document doc2(fromjson("{a: [{b: 0, c: 0}, {c: 0, d: 0}]}"));
resetApplyParams();
setMatchedField("1");
addIndexedPath("a");
@@ -2427,7 +2426,7 @@ TEST_F(UpdateObjectNodeTest, ApplyToArrayByIndexWithLeadingZero) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{a: [0, 0, 0, 0, 0]}"));
+ mutablebson::Document doc(fromjson("{a: [0, 0, 0, 0, 0]}"));
addIndexedPath("a");
auto result = root.apply(getApplyParams(doc.root()));
ASSERT_TRUE(result.indexesAffected);
@@ -2462,7 +2461,7 @@ TEST_F(UpdateObjectNodeTest, ApplyMultipleArrayUpdates) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{a: []}"));
+ mutablebson::Document doc(fromjson("{a: []}"));
addIndexedPath("a");
auto result = root.apply(getApplyParams(doc.root()));
ASSERT_TRUE(result.indexesAffected);
@@ -2487,7 +2486,7 @@ TEST_F(UpdateObjectNodeTest, ApplyUpdateToNonViablePathInArray) {
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{a: [{b: 1}, {b: 2}]}"));
+ mutablebson::Document doc(fromjson("{a: [{b: 1}, {b: 2}]}"));
addIndexedPath("a");
ASSERT_THROWS_CODE_AND_WHAT(root.apply(getApplyParams(doc.root())),
UserException,
@@ -2514,7 +2513,7 @@ TEST_F(UpdateObjectNodeTest, SetAndPopModifiersWithCommonPrefixApplySuccessfully
arrayFilters,
foundIdentifiers));
- Document doc(fromjson("{a: {b: 3, c: [1, 2, 3, 4]}}"));
+ mutablebson::Document doc(fromjson("{a: {b: 3, c: [1, 2, 3, 4]}}"));
auto result = root.apply(getApplyParams(doc.root()));
ASSERT_FALSE(result.indexesAffected);
ASSERT_FALSE(result.noop);