summaryrefslogtreecommitdiff
path: root/src/mongo/db/ops
diff options
context:
space:
mode:
authorScott Hernandez <scotthernandez@gmail.com>2013-12-11 11:00:32 -0500
committerScott Hernandez <scotthernandez@gmail.com>2013-12-13 15:51:49 -0500
commit34738d8f39dae85b10687b207473e61b52b5b93c (patch)
treeef13e89af32eb2696824b19b7b7ca8d23ad9eb76 /src/mongo/db/ops
parent2c54682ce88e2c4e7fe8c99baeadfece0831dbd2 (diff)
downloadmongo-34738d8f39dae85b10687b207473e61b52b5b93c.tar.gz
SERVER-12029: use $unset true in logbuilder, and unset mod
Diffstat (limited to 'src/mongo/db/ops')
-rw-r--r--src/mongo/db/ops/log_builder.cpp33
-rw-r--r--src/mongo/db/ops/log_builder.h20
-rw-r--r--src/mongo/db/ops/log_builder_test.cpp52
-rw-r--r--src/mongo/db/ops/modifier_pop.cpp17
-rw-r--r--src/mongo/db/ops/modifier_pull.cpp8
-rw-r--r--src/mongo/db/ops/modifier_pull_all.cpp24
-rw-r--r--src/mongo/db/ops/modifier_pull_test.cpp6
-rw-r--r--src/mongo/db/ops/modifier_rename.cpp8
-rw-r--r--src/mongo/db/ops/modifier_unset.cpp16
-rw-r--r--src/mongo/db/ops/modifier_unset_test.cpp52
10 files changed, 66 insertions, 170 deletions
diff --git a/src/mongo/db/ops/log_builder.cpp b/src/mongo/db/ops/log_builder.cpp
index 9a92e13bfa9..8b58de50f1c 100644
--- a/src/mongo/db/ops/log_builder.cpp
+++ b/src/mongo/db/ops/log_builder.cpp
@@ -128,36 +128,13 @@ namespace mongo {
return addToSets(elemToSet);
}
- Status LogBuilder::addToUnsets(Element elt) {
- return addToSection(elt, &_unsetAccumulator, kUnset);
- }
-
- Status LogBuilder::addToUnsetsWithNewFieldName(const StringData& name,
- const mutablebson::Element val) {
- mutablebson::Element elemToSet =
- _logRoot.getDocument().makeElementWithNewFieldName(name, val);
- if (!elemToSet.ok())
- return Status(ErrorCodes::InternalError,
- str::stream() << "Could not create new '"
- << name << "' element from existing element '"
- << val.getFieldName() << "' of type "
- << typeName(val.getType()));
-
- return addToUnsets(elemToSet);
- }
-
- Status LogBuilder::addToUnsetsWithNewFieldName(const StringData& name,
- const BSONElement& val){
- mutablebson::Element elemToSet =
- _logRoot.getDocument().makeElementWithNewFieldName(name, val);
- if (!elemToSet.ok())
+ Status LogBuilder::addToUnsets(StringData path) {
+ mutablebson::Element logElement = _logRoot.getDocument().makeElementBool(path, true);
+ if (!logElement.ok())
return Status(ErrorCodes::InternalError,
- str::stream() << "Could not create new '"
- << name << "' element from existing element '"
- << val.fieldName() << "' of type "
- << typeName(val.type()));
+ str::stream() << "Cannot create $unset oplog entry for path" << path);
- return addToUnsets(elemToSet);
+ return addToSection(logElement, &_unsetAccumulator, kUnset);
}
Status LogBuilder::getReplacementObject(Element* outElt) {
diff --git a/src/mongo/db/ops/log_builder.h b/src/mongo/db/ops/log_builder.h
index b1cd1468978..7f422e06224 100644
--- a/src/mongo/db/ops/log_builder.h
+++ b/src/mongo/db/ops/log_builder.h
@@ -88,28 +88,12 @@ namespace mongo {
*/
Status addToSetsWithNewFieldName(const StringData& name, const BSONElement& val);
- /** Add the given Element as a new entry in the '$unset' section of the log. If an
+ /** Add the given path as a new entry in the '$unset' section of the log. If an
* '$unset' section does not yet exist, it will be created. If this LogBuilder is
* currently configured to contain an object replacement, the request to add to the
* $unset section will return an Error.
*/
- Status addToUnsets(mutablebson::Element elt);
-
- /**
- * Convenience method which calls addToUnsets after
- * creating a new Element to wrap the old one.
- *
- * If any problem occurs then the operation will stop and return that error Status.
- */
- Status addToUnsetsWithNewFieldName(const StringData& name, const mutablebson::Element val);
-
- /**
- * Convenience method which calls addToUnsets after
- * creating a new Element to wrap the old one.
- *
- * If any problem occurs then the operation will stop and return that error Status.
- */
- Status addToUnsetsWithNewFieldName(const StringData& name, const BSONElement& val);
+ Status addToUnsets(StringData path);
/** Obtain, via the out parameter 'outElt', a pointer to the mongo::Object type Element
* to which the components of an object replacement should be recorded. It is an error
diff --git a/src/mongo/db/ops/log_builder_test.cpp b/src/mongo/db/ops/log_builder_test.cpp
index 9e2e480785f..8b5ee877ecf 100644
--- a/src/mongo/db/ops/log_builder_test.cpp
+++ b/src/mongo/db/ops/log_builder_test.cpp
@@ -80,34 +80,8 @@ namespace {
TEST(LogBuilder, AddOneToUnset) {
mmb::Document doc;
LogBuilder lb(doc.root());
-
- const mmb::Element elt_xy = doc.makeElementInt("x.y", 1);
- ASSERT_TRUE(elt_xy.ok());
- ASSERT_OK(lb.addToUnsets(elt_xy));
-
- ASSERT_EQUALS(mongo::fromjson("{ $unset : { 'x.y' : 1 } }"), doc);
- }
-
- TEST(LogBuilder, AddElementToUnset) {
- mmb::Document doc;
- LogBuilder lb(doc.root());
-
- const mmb::Element elt_ab = doc.makeElementInt("", 1);
- ASSERT_TRUE(elt_ab.ok());
- ASSERT_OK(lb.addToUnsetsWithNewFieldName("a.b", elt_ab));
-
- ASSERT_EQUALS(mongo::fromjson("{ $unset : { 'a.b' : 1 } }"), doc);
- }
-
- TEST(LogBuilder, AddBSONElementToUnset) {
- mmb::Document doc;
- LogBuilder lb(doc.root());
-
- mongo::BSONObj obj = mongo::fromjson("{'':1}");
-
- ASSERT_OK(lb.addToUnsetsWithNewFieldName("a.b", obj.firstElement()));
-
- ASSERT_EQUALS(mongo::fromjson("{ $unset : { 'a.b' : 1 } }"), doc);
+ ASSERT_OK(lb.addToUnsets("x.y"));
+ ASSERT_EQUALS(mongo::fromjson("{ $unset : { 'x.y' : true } }"), doc);
}
TEST(LogBuilder, AddOneToEach) {
@@ -118,15 +92,13 @@ namespace {
ASSERT_TRUE(elt_ab.ok());
ASSERT_OK(lb.addToSets(elt_ab));
- const mmb::Element elt_xy = doc.makeElementInt("x.y", 1);
- ASSERT_TRUE(elt_xy.ok());
- ASSERT_OK(lb.addToUnsets(elt_xy));
+ ASSERT_OK(lb.addToUnsets("x.y"));
ASSERT_EQUALS(
mongo::fromjson(
"{ "
" $set : { 'a.b' : 1 }, "
- " $unset : { 'x.y' : 1 } "
+ " $unset : { 'x.y' : true } "
"}"
), doc);
}
@@ -194,19 +166,14 @@ namespace {
mmb::Document doc;
LogBuilder lb(doc.root());
- const mmb::Element elt_ab = doc.makeElementInt("a.b", 1);
- ASSERT_TRUE(elt_ab.ok());
- ASSERT_OK(lb.addToUnsets(elt_ab));
-
- const mmb::Element elt_xy = doc.makeElementInt("x.y", 1);
- ASSERT_TRUE(elt_xy.ok());
- ASSERT_OK(lb.addToUnsets(elt_xy));
+ ASSERT_OK(lb.addToUnsets("a.b"));
+ ASSERT_OK(lb.addToUnsets("x.y"));
ASSERT_EQUALS(
mongo::fromjson(
"{ $unset : {"
- " 'a.b' : 1, "
- " 'x.y' : 1 "
+ " 'a.b' : true, "
+ " 'x.y' : true "
"} }"
), doc);
}
@@ -273,8 +240,7 @@ namespace {
ASSERT_TRUE(replacement.ok());
ASSERT_OK(replacement.appendInt("a", 1));
- mmb::Element setCandidate = doc.makeElementInt("x", 0);
- ASSERT_NOT_OK(lb.addToUnsets(setCandidate));
+ ASSERT_NOT_OK(lb.addToUnsets("x"));
}
// Ensure that once you have obtained the object replacement slot and mutated it, that the
diff --git a/src/mongo/db/ops/modifier_pop.cpp b/src/mongo/db/ops/modifier_pop.cpp
index 1c21e776284..be634a72992 100644
--- a/src/mongo/db/ops/modifier_pop.cpp
+++ b/src/mongo/db/ops/modifier_pop.cpp
@@ -189,12 +189,13 @@ namespace mongo {
const bool pathExists = _preparedState->pathFoundElement.ok() &&
(_preparedState->pathFoundIndex == (_fieldRef.numParts() - 1));
+ if (!pathExists)
+ return logBuilder->addToUnsets(_fieldRef.dottedField());
+
// value for the logElement ("field.path.name": <value>)
- mutablebson::Element logElement = pathExists ?
- doc.makeElementWithNewFieldName(
- _fieldRef.dottedField(),
- _preparedState->pathFoundElement) :
- doc.makeElementBool(_fieldRef.dottedField(), true);
+ mutablebson::Element logElement = doc.makeElementWithNewFieldName(
+ _fieldRef.dottedField(),
+ _preparedState->pathFoundElement);
if (!logElement.ok()) {
return Status(ErrorCodes::InternalError,
@@ -202,10 +203,6 @@ namespace mongo {
<< "set '" << _fieldRef.dottedField() << "' -> "
<< _preparedState->pathFoundElement.toString() );
}
-
- // Now, we attach the {<fieldname>: <value>} Element under the {$op: ...} one.
- return pathExists ?
- logBuilder->addToSets(logElement) :
- logBuilder->addToUnsets(logElement);
+ return logBuilder->addToSets(logElement);
}
} // namespace mongo
diff --git a/src/mongo/db/ops/modifier_pull.cpp b/src/mongo/db/ops/modifier_pull.cpp
index ce159467fd6..101bef175b5 100644
--- a/src/mongo/db/ops/modifier_pull.cpp
+++ b/src/mongo/db/ops/modifier_pull.cpp
@@ -230,13 +230,7 @@ namespace mongo {
// If we didn't find the element that we wanted to pull from, we log an unset for
// that element.
-
- mb::Element logElement = doc.makeElementInt(_fieldRef.dottedField(), 1);
- if (!logElement.ok())
- return Status(ErrorCodes::InternalError,
- "cannot create log entry for $pull mod");
-
- return logBuilder->addToUnsets(logElement);
+ return logBuilder->addToUnsets(_fieldRef.dottedField());
} else {
diff --git a/src/mongo/db/ops/modifier_pull_all.cpp b/src/mongo/db/ops/modifier_pull_all.cpp
index eb03c1bc314..f330e91b5e2 100644
--- a/src/mongo/db/ops/modifier_pull_all.cpp
+++ b/src/mongo/db/ops/modifier_pull_all.cpp
@@ -225,25 +225,23 @@ namespace mongo {
Status ModifierPullAll::log(LogBuilder* logBuilder) const {
// log document
mutablebson::Document& doc = logBuilder->getDocument();
-
const bool pathExists = _preparedState->pathFoundElement.ok() &&
(_preparedState->pathFoundIndex == (_fieldRef.numParts() - 1));
+ if (!pathExists)
+ return logBuilder->addToUnsets(_fieldRef.dottedField());
+
// value for the logElement ("field.path.name": <value>)
- mutablebson::Element logElement = pathExists ?
- doc.makeElementWithNewFieldName(
- _fieldRef.dottedField(),
- _preparedState->pathFoundElement):
- doc.makeElementBool(_fieldRef.dottedField(), true);
+ mutablebson::Element logElement = doc.makeElementWithNewFieldName(
+ _fieldRef.dottedField(),
+ _preparedState->pathFoundElement);
if (!logElement.ok()) {
- return Status(ErrorCodes::InternalError, "cannot create details");
+ return Status(ErrorCodes::InternalError,
+ str::stream() << "Could not append entry to $pullAll oplog entry: "
+ << "set '" << _fieldRef.dottedField() << "' -> "
+ << _preparedState->pathFoundElement.toString() );
}
-
- // Now, we attach the {<fieldname>: <value>} Element under the {$op: ...} one.
- return pathExists ?
- logBuilder->addToSets(logElement) :
- logBuilder->addToUnsets(logElement);
+ return logBuilder->addToSets(logElement);
}
-
} // namespace mongo
diff --git a/src/mongo/db/ops/modifier_pull_test.cpp b/src/mongo/db/ops/modifier_pull_test.cpp
index ccb6a5429f7..af457dd8cbc 100644
--- a/src/mongo/db/ops/modifier_pull_test.cpp
+++ b/src/mongo/db/ops/modifier_pull_test.cpp
@@ -97,7 +97,7 @@ namespace {
Document logDoc;
LogBuilder logBuilder(logDoc.root());
ASSERT_OK(mod.log(&logBuilder));
- ASSERT_EQUALS(fromjson("{ $unset : { a : 1 } }"), logDoc);
+ ASSERT_EQUALS(fromjson("{ $unset : { a : true } }"), logDoc);
}
TEST(SimpleMod, PrepareOKTargetFound) {
@@ -138,7 +138,7 @@ namespace {
Document logDoc;
LogBuilder logBuilder(logDoc.root());
ASSERT_OK(mod.log(&logBuilder));
- ASSERT_EQUALS(fromjson("{ $unset : { a : 1 } }"), logDoc);
+ ASSERT_EQUALS(fromjson("{ $unset : { a : true } }"), logDoc);
}
TEST(SimpleMod, PrepareAndLogMissingElementAfterFoundPath) {
@@ -153,7 +153,7 @@ namespace {
Document logDoc;
LogBuilder logBuilder(logDoc.root());
ASSERT_OK(mod.log(&logBuilder));
- ASSERT_EQUALS(fromjson("{ $unset : { 'a.b.c.d' : 1 } }"), logDoc);
+ ASSERT_EQUALS(fromjson("{ $unset : { 'a.b.c.d' : true } }"), logDoc);
}
TEST(SimpleMod, PrepareAndLogEmptyArray) {
diff --git a/src/mongo/db/ops/modifier_rename.cpp b/src/mongo/db/ops/modifier_rename.cpp
index 4cb643f297b..c29f60ccdd7 100644
--- a/src/mongo/db/ops/modifier_rename.cpp
+++ b/src/mongo/db/ops/modifier_rename.cpp
@@ -300,13 +300,7 @@ namespace mongo {
// dotted field, if it was applied over a dotted field. The rationale is that the
// secondary may be in a different state than the primary and thus make different
// decisions about creating the intermediate path in _fieldRef or not.
- mutablebson::Element unsetEntry = doc.makeElementBool(unsetPath, true);
- if (!unsetEntry.ok()) {
- return Status(ErrorCodes::InternalError, "cannot create details for $rename mod");
- }
-
- // Now, we attach the Element under the {$unset: ...} section.
- status = logBuilder->addToUnsets(unsetEntry);
+ status = logBuilder->addToUnsets(unsetPath);
}
return status;
diff --git a/src/mongo/db/ops/modifier_unset.cpp b/src/mongo/db/ops/modifier_unset.cpp
index 2e55fe0b5e8..7a59c0ba261 100644
--- a/src/mongo/db/ops/modifier_unset.cpp
+++ b/src/mongo/db/ops/modifier_unset.cpp
@@ -179,21 +179,7 @@ namespace mongo {
}
Status ModifierUnset::log(LogBuilder* logBuilder) const {
-
- // We'd like to create an entry such as {$unset: {<fieldname>: 1}} under 'logRoot'.
- // We start by creating the {$unset: ...} Element.
- mutablebson::Document& doc = logBuilder->getDocument();
-
- // Create the {<fieldname>: <value>} Element. Note that <fieldname> must be a
- // dotted field, and not only the last part of that field. The rationale here is that
- // somoene picking up this log entry -- e.g., a secondary -- must be capable of doing
- // the same path find/creation that was done in the previous calls here.
- mutablebson::Element logElement = doc.makeElementInt(_fieldRef.dottedField(), 1);
- if (!logElement.ok()) {
- return Status(ErrorCodes::InternalError, "cannot create log details for $unset mod");
- }
-
- return logBuilder->addToUnsets(logElement);
+ return logBuilder->addToUnsets(_fieldRef.dottedField());
}
} // namespace mongo
diff --git a/src/mongo/db/ops/modifier_unset_test.cpp b/src/mongo/db/ops/modifier_unset_test.cpp
index 4a7998c4cd0..d181bd57d99 100644
--- a/src/mongo/db/ops/modifier_unset_test.cpp
+++ b/src/mongo/db/ops/modifier_unset_test.cpp
@@ -93,7 +93,7 @@ namespace {
TEST(SimpleMod, PrepareNoOp) {
Document doc(fromjson("{}"));
- Mod modUnset(fromjson("{$unset: {a: 1}}"));
+ Mod modUnset(fromjson("{$unset: {a: true}}"));
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(modUnset.prepare(doc.root(), "", &execInfo));
@@ -104,7 +104,7 @@ namespace {
TEST(SimpleMod, PrepareApplyNormal) {
Document doc(fromjson("{a: 1, b: 2}"));
- Mod modUnset(fromjson("{$unset: {a: 1}}"));
+ Mod modUnset(fromjson("{$unset: {a: true}}"));
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(modUnset.prepare(doc.root(), "", &execInfo));
@@ -119,7 +119,7 @@ namespace {
TEST(SimpleMod, PrepareApplyInPlace) {
Document doc(fromjson("{x: 0, a: 1}"));
- Mod modUnset(fromjson("{$unset: {a: 1}}"));
+ Mod modUnset(fromjson("{$unset: {a: true}}"));
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(modUnset.prepare(doc.root(), "", &execInfo));
@@ -134,7 +134,7 @@ namespace {
TEST(SimpleMod, PrepareApplyGeneratesEmptyDocument) {
Document doc(fromjson("{a: 1}"));
- Mod modUnset(fromjson("{$unset: {a: 1}}"));
+ Mod modUnset(fromjson("{$unset: {a: true}}"));
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(modUnset.prepare(doc.root(), "", &execInfo));
@@ -149,7 +149,7 @@ namespace {
TEST(SimpleMod, PrepareApplyUnsetSubtree) {
Document doc(fromjson("{a: {b: 1}, c: 2}"));
- Mod modUnset(fromjson("{$unset: {a: 1}}"));
+ Mod modUnset(fromjson("{$unset: {a: true}}"));
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(modUnset.prepare(doc.root(), "", &execInfo));
@@ -165,7 +165,7 @@ namespace {
TEST(SimpleMod, LogNormal) {
BSONObj obj = fromjson("{a: 1}");
Document doc(obj);
- Mod modUnset(fromjson("{$unset: {a: 1}}"));
+ Mod modUnset(fromjson("{$unset: {a: true}}"));
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(modUnset.prepare(doc.root(), "", &execInfo));
@@ -185,7 +185,7 @@ namespace {
TEST(DottedMod, PrepareNoOp) {
Document doc(fromjson("{c:2}"));
- Mod modUnset(fromjson("{$unset: {'a.b': 1}}"));
+ Mod modUnset(fromjson("{$unset: {'a.b': true}}"));
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(modUnset.prepare(doc.root(), "", &execInfo));
@@ -196,7 +196,7 @@ namespace {
TEST(DottedMod, PrepareApplyNormal) {
Document doc(fromjson("{a: {b: 1}, c: 2}"));
- Mod modUnset(fromjson("{$unset: {'a.b': 1}}"));
+ Mod modUnset(fromjson("{$unset: {'a.b': true}}"));
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(modUnset.prepare(doc.root(), "", &execInfo));
@@ -211,7 +211,7 @@ namespace {
TEST(DottedMod, PrepareApplyInPlace) {
Document doc(fromjson("{x: 0, a: {b: 1}}"));
- Mod modUnset(fromjson("{$unset: {'a.b': 1}}"));
+ Mod modUnset(fromjson("{$unset: {'a.b': true}}"));
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(modUnset.prepare(doc.root(), "", &execInfo));
@@ -226,7 +226,7 @@ namespace {
TEST(DottedMod, PrepareApplyUnsetNestedSubobject) {
Document doc(fromjson("{a: {b: {c: 1}}}"));
- Mod modUnset(fromjson("{$unset: {'a.b': 1}}"));
+ Mod modUnset(fromjson("{$unset: {'a.b': true}}"));
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(modUnset.prepare(doc.root(), "", &execInfo));
@@ -245,7 +245,7 @@ namespace {
TEST(IndexedMod, PrepareNoOp) {
Document doc(fromjson("{a:[]}"));
- Mod modUnset(fromjson("{$unset: {'a.0': 1}}"));
+ Mod modUnset(fromjson("{$unset: {'a.0': true}}"));
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(modUnset.prepare(doc.root(), "", &execInfo));
@@ -256,7 +256,7 @@ namespace {
TEST(IndexedMod, PrepareApplyNormal) {
Document doc(fromjson("{a:[0,1,2]}"));
- Mod modUnset(fromjson("{$unset: {'a.0': 1}}"));
+ Mod modUnset(fromjson("{$unset: {'a.0': true}}"));
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(modUnset.prepare(doc.root(), "", &execInfo));
@@ -271,7 +271,7 @@ namespace {
TEST(IndexedMod, PrepareApplyInPlace) {
Document doc(fromjson("{b:1, a:[1]}"));
- Mod modUnset(fromjson("{$unset: {'a.0': 1}}"));
+ Mod modUnset(fromjson("{$unset: {'a.0': true}}"));
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(modUnset.prepare(doc.root(), "", &execInfo));
@@ -287,7 +287,7 @@ namespace {
TEST(IndexedMod, PrepareApplyInPlaceNuance) {
// Can't change the encoding in the middle of a bson stream.
Document doc(fromjson("{a:[1], b:1}"));
- Mod modUnset(fromjson("{$unset: {'a.0': 1}}"));
+ Mod modUnset(fromjson("{$unset: {'a.0': true}}"));
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(modUnset.prepare(doc.root(), "", &execInfo));
@@ -302,7 +302,7 @@ namespace {
TEST(IndexedMod, PrepareApplyInnerObject) {
Document doc(fromjson("{a:[{b:1}]}"));
- Mod modUnset(fromjson("{$unset: {'a.0.b': 1}}"));
+ Mod modUnset(fromjson("{$unset: {'a.0.b': true}}"));
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(modUnset.prepare(doc.root(), "", &execInfo));
@@ -317,7 +317,7 @@ namespace {
TEST(IndexedMod, PrepareApplyObject) {
Document doc(fromjson("{a:[{b:1}]}"));
- Mod modUnset(fromjson("{$unset: {'a.0': 1}}"));
+ Mod modUnset(fromjson("{$unset: {'a.0': true}}"));
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(modUnset.prepare(doc.root(), "", &execInfo));
@@ -332,7 +332,7 @@ namespace {
TEST(IndexedMod, LogNormal) {
Document doc(fromjson("{a:[0,1,2]}"));
- Mod modUnset(fromjson("{$unset: {'a.0': 1}}"));
+ Mod modUnset(fromjson("{$unset: {'a.0': true}}"));
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(modUnset.prepare(doc.root(), "", &execInfo));
@@ -349,7 +349,7 @@ namespace {
TEST(PositionalMod, PrepareNoOp) {
Document doc(fromjson("{a:[{b:0}]}"));
- Mod modUnset(fromjson("{$unset: {'a.$.b': 1}}"));
+ Mod modUnset(fromjson("{$unset: {'a.$.b': true}}"));
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(modUnset.prepare(doc.root(), "1", &execInfo));
@@ -360,7 +360,7 @@ namespace {
TEST(PositionalMod, PrepareMissingPositional) {
Document doc(fromjson("{a:[{b:0},{c:1}]}"));
- Mod modUnset(fromjson("{$unset: {'a.$.b': 1}}"));
+ Mod modUnset(fromjson("{$unset: {'a.$.b': true}}"));
ModifierInterface::ExecInfo execInfo;
ASSERT_NOT_OK(modUnset.prepare(doc.root(), "" /* no position */, &execInfo));
@@ -368,7 +368,7 @@ namespace {
TEST(PositionalMod, PrepareApplyNormal) {
Document doc(fromjson("{a:[{b:0},{c:1}]}"));
- Mod modUnset(fromjson("{$unset: {'a.$.b': 1}}"));
+ Mod modUnset(fromjson("{$unset: {'a.$.b': true}}"));
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(modUnset.prepare(doc.root(), "0", &execInfo));
@@ -383,7 +383,7 @@ namespace {
TEST(PositionalMod, PrepareApplyObject) {
Document doc(fromjson("{a:[{b:0},{c:1}]}"));
- Mod modUnset(fromjson("{$unset: {'a.$': 1}}"));
+ Mod modUnset(fromjson("{$unset: {'a.$': true}}"));
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(modUnset.prepare(doc.root(), "0", &execInfo));
@@ -398,7 +398,7 @@ namespace {
TEST(PositionalMod, PrepareApplyInPlace) {
Document doc(fromjson("{b:1, a:[{b:1}]}"));
- Mod modUnset(fromjson("{$unset: {'a.$.b': 1}}"));
+ Mod modUnset(fromjson("{$unset: {'a.$.b': true}}"));
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(modUnset.prepare(doc.root(), "0", &execInfo));
@@ -413,7 +413,7 @@ namespace {
TEST(PositionalMod, LogNormal) {
Document doc(fromjson("{b:1, a:[{b:1}]}"));
- Mod modUnset(fromjson("{$unset: {'a.$.b': 1}}"));
+ Mod modUnset(fromjson("{$unset: {'a.$.b': true}}"));
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(modUnset.prepare(doc.root(), "0", &execInfo));
@@ -424,12 +424,12 @@ namespace {
Document logDoc;
LogBuilder logBuilder(logDoc.root());
ASSERT_OK(modUnset.log(&logBuilder));
- ASSERT_EQUALS(fromjson("{$unset: {'a.0.b': 1}}"), logDoc);
+ ASSERT_EQUALS(fromjson("{$unset: {'a.0.b': true}}"), logDoc);
}
TEST(LegacyData, CanUnsetInvalidField) {
Document doc(fromjson("{b:1, a:[{$b:1}]}"));
- Mod modUnset(fromjson("{$unset: {'a.$.$b': 1}}"));
+ Mod modUnset(fromjson("{$unset: {'a.$.$b': true}}"));
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(modUnset.prepare(doc.root(), "0", &execInfo));
@@ -444,7 +444,7 @@ namespace {
Document logDoc;
LogBuilder logBuilder(logDoc.root());
ASSERT_OK(modUnset.log(&logBuilder));
- ASSERT_EQUALS(fromjson("{$unset: {'a.0.$b': 1}}"), logDoc);
+ ASSERT_EQUALS(fromjson("{$unset: {'a.0.$b': true}}"), logDoc);
}