summaryrefslogtreecommitdiff
path: root/src/mongo/db/ops
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/ops')
-rw-r--r--src/mongo/db/ops/field_checker.cpp3
-rw-r--r--src/mongo/db/ops/insert.cpp14
-rw-r--r--src/mongo/db/ops/log_builder.cpp12
-rw-r--r--src/mongo/db/ops/log_builder_test.cpp27
-rw-r--r--src/mongo/db/ops/modifier_add_to_set.cpp17
-rw-r--r--src/mongo/db/ops/modifier_bit.cpp18
-rw-r--r--src/mongo/db/ops/modifier_compare.cpp3
-rw-r--r--src/mongo/db/ops/modifier_current_date.cpp6
-rw-r--r--src/mongo/db/ops/modifier_inc.cpp23
-rw-r--r--src/mongo/db/ops/modifier_object_replace.cpp9
-rw-r--r--src/mongo/db/ops/modifier_pop.cpp13
-rw-r--r--src/mongo/db/ops/modifier_pop_test.cpp2
-rw-r--r--src/mongo/db/ops/modifier_pull.cpp3
-rw-r--r--src/mongo/db/ops/modifier_pull_all.cpp13
-rw-r--r--src/mongo/db/ops/modifier_push.cpp29
-rw-r--r--src/mongo/db/ops/modifier_push_sorter.h2
-rw-r--r--src/mongo/db/ops/modifier_push_test.cpp34
-rw-r--r--src/mongo/db/ops/modifier_rename.cpp21
-rw-r--r--src/mongo/db/ops/modifier_set.cpp3
-rw-r--r--src/mongo/db/ops/modifier_unset.cpp3
-rw-r--r--src/mongo/db/ops/parsed_delete.cpp2
-rw-r--r--src/mongo/db/ops/parsed_update.h2
-rw-r--r--src/mongo/db/ops/path_support.cpp9
-rw-r--r--src/mongo/db/ops/path_support_test.cpp16
-rw-r--r--src/mongo/db/ops/update.cpp3
-rw-r--r--src/mongo/db/ops/update.h2
-rw-r--r--src/mongo/db/ops/update_driver.cpp18
-rw-r--r--src/mongo/db/ops/update_lifecycle_impl.cpp4
-rw-r--r--src/mongo/db/ops/update_request.h2
-rw-r--r--src/mongo/db/ops/update_result.h2
-rw-r--r--src/mongo/db/ops/write_ops_exec.cpp7
-rw-r--r--src/mongo/db/ops/write_ops_parsers.cpp23
-rw-r--r--src/mongo/db/ops/write_ops_parsers.h2
-rw-r--r--src/mongo/db/ops/write_ops_parsers_test.cpp68
34 files changed, 259 insertions, 156 deletions
diff --git a/src/mongo/db/ops/field_checker.cpp b/src/mongo/db/ops/field_checker.cpp
index 0c71c7e5d07..4e8c8b82de6 100644
--- a/src/mongo/db/ops/field_checker.cpp
+++ b/src/mongo/db/ops/field_checker.cpp
@@ -51,7 +51,8 @@ Status isUpdatable(const FieldRef& field) {
if (part.empty()) {
return Status(ErrorCodes::EmptyFieldName,
mongoutils::str::stream()
- << "The update path '" << field.dottedField()
+ << "The update path '"
+ << field.dottedField()
<< "' contains an empty field name, which is not allowed.");
}
}
diff --git a/src/mongo/db/ops/insert.cpp b/src/mongo/db/ops/insert.cpp
index de198beac53..c7648b0f254 100644
--- a/src/mongo/db/ops/insert.cpp
+++ b/src/mongo/db/ops/insert.cpp
@@ -42,8 +42,10 @@ StatusWith<BSONObj> fixDocumentForInsert(const BSONObj& doc) {
if (doc.objsize() > BSONObjMaxUserSize)
return StatusWith<BSONObj>(ErrorCodes::BadValue,
str::stream() << "object to insert too large"
- << ". size in bytes: " << doc.objsize()
- << ", max size: " << BSONObjMaxUserSize);
+ << ". size in bytes: "
+ << doc.objsize()
+ << ", max size: "
+ << BSONObjMaxUserSize);
bool firstElementIsId = false;
bool hasTimestampToFix = false;
@@ -162,9 +164,11 @@ Status userAllowedCreateNS(StringData db, StringData coll) {
if (db.size() + 1 /* dot */ + coll.size() > NamespaceString::MaxNsCollectionLen)
return Status(ErrorCodes::BadValue,
- str::stream()
- << "fully qualified namespace " << db << '.' << coll << " is too long "
- << "(max is " << NamespaceString::MaxNsCollectionLen << " bytes)");
+ str::stream() << "fully qualified namespace " << db << '.' << coll
+ << " is too long "
+ << "(max is "
+ << NamespaceString::MaxNsCollectionLen
+ << " bytes)");
// check spceial areas
diff --git a/src/mongo/db/ops/log_builder.cpp b/src/mongo/db/ops/log_builder.cpp
index 21baffe246c..355ccb092e8 100644
--- a/src/mongo/db/ops/log_builder.cpp
+++ b/src/mongo/db/ops/log_builder.cpp
@@ -89,8 +89,10 @@ Status LogBuilder::addToSetsWithNewFieldName(StringData name, const mutablebson:
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()));
+ << "' element from existing element '"
+ << val.getFieldName()
+ << "' of type "
+ << typeName(val.getType()));
return addToSets(elemToSet);
}
@@ -100,8 +102,10 @@ Status LogBuilder::addToSetsWithNewFieldName(StringData name, const BSONElement&
if (!elemToSet.ok())
return Status(ErrorCodes::InternalError,
str::stream() << "Could not create new '" << name
- << "' element from existing element '" << val.fieldName()
- << "' of type " << typeName(val.type()));
+ << "' element from existing element '"
+ << val.fieldName()
+ << "' of type "
+ << typeName(val.type()));
return addToSets(elemToSet);
}
diff --git a/src/mongo/db/ops/log_builder_test.cpp b/src/mongo/db/ops/log_builder_test.cpp
index f2a3d20aa78..a957194e56f 100644
--- a/src/mongo/db/ops/log_builder_test.cpp
+++ b/src/mongo/db/ops/log_builder_test.cpp
@@ -106,11 +106,10 @@ TEST(LogBuilder, AddOneToEach) {
ASSERT_OK(lb.addToUnsets("x.y"));
- ASSERT_EQUALS(mongo::fromjson(
- "{ "
- " $set : { 'a.b' : 1 }, "
- " $unset : { 'x.y' : true } "
- "}"),
+ ASSERT_EQUALS(mongo::fromjson("{ "
+ " $set : { 'a.b' : 1 }, "
+ " $unset : { 'x.y' : true } "
+ "}"),
doc);
}
@@ -164,11 +163,10 @@ TEST(LogBuilder, VerifySetsAreGrouped) {
ASSERT_TRUE(elt_xy.ok());
ASSERT_OK(lb.addToSets(elt_xy));
- ASSERT_EQUALS(mongo::fromjson(
- "{ $set : {"
- " 'a.b' : 1, "
- " 'x.y' : 1 "
- "} }"),
+ ASSERT_EQUALS(mongo::fromjson("{ $set : {"
+ " 'a.b' : 1, "
+ " 'x.y' : 1 "
+ "} }"),
doc);
}
@@ -179,11 +177,10 @@ TEST(LogBuilder, VerifyUnsetsAreGrouped) {
ASSERT_OK(lb.addToUnsets("a.b"));
ASSERT_OK(lb.addToUnsets("x.y"));
- ASSERT_EQUALS(mongo::fromjson(
- "{ $unset : {"
- " 'a.b' : true, "
- " 'x.y' : true "
- "} }"),
+ ASSERT_EQUALS(mongo::fromjson("{ $unset : {"
+ " 'a.b' : true, "
+ " 'x.y' : true "
+ "} }"),
doc);
}
diff --git a/src/mongo/db/ops/modifier_add_to_set.cpp b/src/mongo/db/ops/modifier_add_to_set.cpp
index 383991c2b1f..ffa9c28ddf4 100644
--- a/src/mongo/db/ops/modifier_add_to_set.cpp
+++ b/src/mongo/db/ops/modifier_add_to_set.cpp
@@ -124,7 +124,8 @@ Status ModifierAddToSet::init(const BSONElement& modExpr, const Options& opts, b
if (foundDollar && foundCount > 1) {
return Status(ErrorCodes::BadValue,
str::stream() << "Too many positional (i.e. '$') elements found in path '"
- << _fieldRef.dottedField() << "'");
+ << _fieldRef.dottedField()
+ << "'");
}
// TODO: The driver could potentially do this re-writing.
@@ -247,11 +248,12 @@ Status ModifierAddToSet::prepare(mb::Element root, StringData matchedField, Exec
if (_preparedState->elemFound.getType() != mongo::Array) {
mb::Element idElem = mb::findElementNamed(root.leftChild(), "_id");
return Status(ErrorCodes::BadValue,
- str::stream()
- << "Cannot apply $addToSet to a non-array field. Field named '"
- << _preparedState->elemFound.getFieldName() << "' has a non-array type "
- << typeName(_preparedState->elemFound.getType()) << " in the document "
- << idElem.toString());
+ str::stream() << "Cannot apply $addToSet to a non-array field. Field named '"
+ << _preparedState->elemFound.getFieldName()
+ << "' has a non-array type "
+ << typeName(_preparedState->elemFound.getType())
+ << " in the document "
+ << idElem.toString());
}
// If the array is empty, then we don't need to check anything: all of the values are
@@ -387,7 +389,8 @@ Status ModifierAddToSet::log(LogBuilder* logBuilder) const {
if (!status.isOK()) {
return Status(ErrorCodes::BadValue,
str::stream() << "Could not append entry for $addToSet oplog entry."
- << "Underlying cause: " << status.toString());
+ << "Underlying cause: "
+ << status.toString());
}
curr = curr.rightSibling();
}
diff --git a/src/mongo/db/ops/modifier_bit.cpp b/src/mongo/db/ops/modifier_bit.cpp
index d6acbfe1ff8..fb7ae3f45eb 100644
--- a/src/mongo/db/ops/modifier_bit.cpp
+++ b/src/mongo/db/ops/modifier_bit.cpp
@@ -84,7 +84,8 @@ Status ModifierBit::init(const BSONElement& modExpr, const Options& opts, bool*
if (foundDollar && foundCount > 1) {
return Status(ErrorCodes::BadValue,
str::stream() << "Too many positional (i.e. '$') elements found in path '"
- << _fieldRef.dottedField() << "'");
+ << _fieldRef.dottedField()
+ << "'");
}
if (modExpr.type() != mongo::Object)
@@ -120,7 +121,9 @@ Status ModifierBit::init(const BSONElement& modExpr, const Options& opts, bool*
return Status(ErrorCodes::BadValue,
str::stream()
<< "The $bit modifier only supports 'and', 'or', and 'xor', not '"
- << payloadFieldName << "' which is an unknown operator: {" << curOp
+ << payloadFieldName
+ << "' which is an unknown operator: {"
+ << curOp
<< "}");
}
@@ -128,7 +131,9 @@ Status ModifierBit::init(const BSONElement& modExpr, const Options& opts, bool*
return Status(ErrorCodes::BadValue,
str::stream()
<< "The $bit modifier field must be an Integer(32/64 bit); a '"
- << typeName(curOp.type()) << "' is not supported here: {" << curOp
+ << typeName(curOp.type())
+ << "' is not supported here: {"
+ << curOp
<< "}");
const OpEntry entry = {SafeNum(curOp), op};
@@ -191,7 +196,8 @@ Status ModifierBit::prepare(mutablebson::Element root,
mb::Element idElem = mb::findElementNamed(root.leftChild(), "_id");
return Status(ErrorCodes::BadValue,
str::stream() << "Cannot apply $bit to a value of non-integral type."
- << idElem.toString() << " has the field "
+ << idElem.toString()
+ << " has the field "
<< _preparedState->elemFound.getFieldName()
<< " of non-integer type "
<< typeName(_preparedState->elemFound.getType()));
@@ -260,7 +266,9 @@ Status ModifierBit::log(LogBuilder* logBuilder) const {
if (!logElement.ok()) {
return Status(ErrorCodes::InternalError,
str::stream() << "Could not append entry to $bit oplog entry: "
- << "set '" << _fieldRef.dottedField() << "' -> "
+ << "set '"
+ << _fieldRef.dottedField()
+ << "' -> "
<< _preparedState->newValue.debugString());
}
return logBuilder->addToSets(logElement);
diff --git a/src/mongo/db/ops/modifier_compare.cpp b/src/mongo/db/ops/modifier_compare.cpp
index 36f800202e4..2d05d29f360 100644
--- a/src/mongo/db/ops/modifier_compare.cpp
+++ b/src/mongo/db/ops/modifier_compare.cpp
@@ -77,7 +77,8 @@ Status ModifierCompare::init(const BSONElement& modExpr, const Options& opts, bo
if (foundDollar && foundCount > 1) {
return Status(ErrorCodes::BadValue,
str::stream() << "Too many positional (i.e. '$') elements found in path '"
- << _updatePath.dottedField() << "'");
+ << _updatePath.dottedField()
+ << "'");
}
// Store value for later.
diff --git a/src/mongo/db/ops/modifier_current_date.cpp b/src/mongo/db/ops/modifier_current_date.cpp
index 75d0be014e3..cd328f5fe94 100644
--- a/src/mongo/db/ops/modifier_current_date.cpp
+++ b/src/mongo/db/ops/modifier_current_date.cpp
@@ -84,7 +84,8 @@ Status ModifierCurrentDate::init(const BSONElement& modExpr,
if (foundDollar && foundCount > 1) {
return Status(ErrorCodes::BadValue,
str::stream() << "Too many positional (i.e. '$') elements found in path '"
- << _updatePath.dottedField() << "'");
+ << _updatePath.dottedField()
+ << "'");
}
// Validate and store the type to produce
@@ -113,7 +114,8 @@ Status ModifierCurrentDate::init(const BSONElement& modExpr,
str::stream()
<< "The only valid field of the option is '$type': "
"{$currentDate: {field : {$type: 'date/timestamp'}}}; "
- << "arg: " << argObj);
+ << "arg: "
+ << argObj);
}
}
}
diff --git a/src/mongo/db/ops/modifier_inc.cpp b/src/mongo/db/ops/modifier_inc.cpp
index 8bc6e2ff9a4..314ac6a5024 100644
--- a/src/mongo/db/ops/modifier_inc.cpp
+++ b/src/mongo/db/ops/modifier_inc.cpp
@@ -89,7 +89,8 @@ Status ModifierInc::init(const BSONElement& modExpr, const Options& opts, bool*
if (foundDollar && foundCount > 1) {
return Status(ErrorCodes::BadValue,
str::stream() << "Too many positional (i.e. '$') elements found in path '"
- << _fieldRef.dottedField() << "'");
+ << _fieldRef.dottedField()
+ << "'");
}
//
@@ -101,7 +102,9 @@ Status ModifierInc::init(const BSONElement& modExpr, const Options& opts, bool*
// include mod code, etc.
return Status(ErrorCodes::TypeMismatch,
str::stream() << "Cannot " << (_mode == MODE_INC ? "increment" : "multiply")
- << " with non-numeric argument: {" << modExpr << "}");
+ << " with non-numeric argument: {"
+ << modExpr
+ << "}");
}
_val = modExpr;
@@ -172,7 +175,8 @@ Status ModifierInc::prepare(mutablebson::Element root,
mb::Element idElem = mb::findFirstChildNamed(root, "_id");
return Status(ErrorCodes::TypeMismatch,
str::stream() << "Cannot apply " << (_mode == MODE_INC ? "$inc" : "$mul")
- << " to a value of non-numeric type. {" << idElem.toString()
+ << " to a value of non-numeric type. {"
+ << idElem.toString()
<< "} has the field '"
<< _preparedState->elemFound.getFieldName()
<< "' of non-numeric type "
@@ -191,8 +195,10 @@ Status ModifierInc::prepare(mutablebson::Element root,
mb::Element idElem = mb::findFirstChildNamed(root, "_id");
return Status(ErrorCodes::BadValue,
str::stream() << "Failed to apply $inc operations to current value ("
- << currentValue.debugString() << ") for document {"
- << idElem.toString() << "}");
+ << currentValue.debugString()
+ << ") for document {"
+ << idElem.toString()
+ << "}");
}
// If the values are identical (same type, same value), then this is a no-op.
@@ -254,8 +260,11 @@ Status ModifierInc::log(LogBuilder* logBuilder) const {
if (!logElement.ok()) {
return Status(ErrorCodes::InternalError,
str::stream() << "Could not append entry to "
- << (_mode == MODE_INC ? "$inc" : "$mul") << " oplog entry: "
- << "set '" << _fieldRef.dottedField() << "' -> "
+ << (_mode == MODE_INC ? "$inc" : "$mul")
+ << " oplog entry: "
+ << "set '"
+ << _fieldRef.dottedField()
+ << "' -> "
<< _preparedState->newValue.debugString());
}
diff --git a/src/mongo/db/ops/modifier_object_replace.cpp b/src/mongo/db/ops/modifier_object_replace.cpp
index 64bec6283d7..0cecd5a0d1e 100644
--- a/src/mongo/db/ops/modifier_object_replace.cpp
+++ b/src/mongo/db/ops/modifier_object_replace.cpp
@@ -86,7 +86,8 @@ Status ModifierObjectReplace::init(const BSONElement& modExpr,
// Impossible, really since the caller check this already...
return Status(ErrorCodes::BadValue,
str::stream() << "Document replacement expects a complete document"
- " but the type supplied was " << modExpr.type());
+ " but the type supplied was "
+ << modExpr.type());
}
// Object replacements never have positional operator.
@@ -150,8 +151,10 @@ Status ModifierObjectReplace::apply() const {
if (srcIdElement.compareWithBSONElement(dstIdElement, true) != 0) {
return Status(ErrorCodes::ImmutableField,
str::stream() << "The _id field cannot be changed from {"
- << srcIdElement.toString() << "} to {"
- << dstIdElement.toString() << "}.");
+ << srcIdElement.toString()
+ << "} to {"
+ << dstIdElement.toString()
+ << "}.");
}
continue;
}
diff --git a/src/mongo/db/ops/modifier_pop.cpp b/src/mongo/db/ops/modifier_pop.cpp
index c46fdd7a9bf..07682c976bf 100644
--- a/src/mongo/db/ops/modifier_pop.cpp
+++ b/src/mongo/db/ops/modifier_pop.cpp
@@ -89,7 +89,8 @@ Status ModifierPop::init(const BSONElement& modExpr, const Options& opts, bool*
if (foundDollar && foundCount > 1) {
return Status(ErrorCodes::BadValue,
str::stream() << "Too many positional (i.e. '$') elements found in path '"
- << _fieldRef.dottedField() << "'");
+ << _fieldRef.dottedField()
+ << "'");
}
//
@@ -136,9 +137,9 @@ Status ModifierPop::prepare(mutablebson::Element root,
// array.
if (_preparedState->pathFoundElement.getType() != Array) {
mb::Element idElem = mb::findFirstChildNamed(root, "_id");
- return Status(ErrorCodes::BadValue,
- str::stream()
- << "Can only $pop from arrays. {" << idElem.toString()
+ return Status(
+ ErrorCodes::BadValue,
+ str::stream() << "Can only $pop from arrays. {" << idElem.toString()
<< "} has the field '"
<< _preparedState->pathFoundElement.getFieldName()
<< "' of non-array type "
@@ -190,7 +191,9 @@ Status ModifierPop::log(LogBuilder* logBuilder) const {
if (!logElement.ok()) {
return Status(ErrorCodes::InternalError,
str::stream() << "Could not append entry to $pop oplog entry: "
- << "set '" << _fieldRef.dottedField() << "' -> "
+ << "set '"
+ << _fieldRef.dottedField()
+ << "' -> "
<< _preparedState->pathFoundElement.toString());
}
return logBuilder->addToSets(logElement);
diff --git a/src/mongo/db/ops/modifier_pop_test.cpp b/src/mongo/db/ops/modifier_pop_test.cpp
index 06dd60a029e..8e288c73aa4 100644
--- a/src/mongo/db/ops/modifier_pop_test.cpp
+++ b/src/mongo/db/ops/modifier_pop_test.cpp
@@ -37,8 +37,8 @@
#include "mongo/bson/mutable/document.h"
#include "mongo/bson/mutable/mutable_bson_test_utils.h"
#include "mongo/db/jsobj.h"
-#include "mongo/db/ops/log_builder.h"
#include "mongo/db/json.h"
+#include "mongo/db/ops/log_builder.h"
#include "mongo/unittest/unittest.h"
namespace {
diff --git a/src/mongo/db/ops/modifier_pull.cpp b/src/mongo/db/ops/modifier_pull.cpp
index ce87c03e0f3..a172251eea6 100644
--- a/src/mongo/db/ops/modifier_pull.cpp
+++ b/src/mongo/db/ops/modifier_pull.cpp
@@ -94,7 +94,8 @@ Status ModifierPull::init(const BSONElement& modExpr, const Options& opts, bool*
if (foundDollar && foundCount > 1) {
return Status(ErrorCodes::BadValue,
str::stream() << "Too many positional (i.e. '$') elements found in path '"
- << _fieldRef.dottedField() << "'");
+ << _fieldRef.dottedField()
+ << "'");
}
_exprElt = modExpr;
diff --git a/src/mongo/db/ops/modifier_pull_all.cpp b/src/mongo/db/ops/modifier_pull_all.cpp
index 287dc4828b4..681769fd195 100644
--- a/src/mongo/db/ops/modifier_pull_all.cpp
+++ b/src/mongo/db/ops/modifier_pull_all.cpp
@@ -105,7 +105,8 @@ Status ModifierPullAll::init(const BSONElement& modExpr, const Options& opts, bo
if (foundDollar && foundCount > 1) {
return Status(ErrorCodes::BadValue,
str::stream() << "Too many positional (i.e. '$') elements found in path '"
- << _fieldRef.dottedField() << "'");
+ << _fieldRef.dottedField()
+ << "'");
}
//
@@ -155,9 +156,9 @@ Status ModifierPullAll::prepare(mutablebson::Element root,
// array.
if (_preparedState->pathFoundElement.getType() != Array) {
mb::Element idElem = mb::findElementNamed(root.leftChild(), "_id");
- return Status(ErrorCodes::BadValue,
- str::stream()
- << "Can only apply $pullAll to an array. " << idElem.toString()
+ return Status(
+ ErrorCodes::BadValue,
+ str::stream() << "Can only apply $pullAll to an array. " << idElem.toString()
<< " has the field "
<< _preparedState->pathFoundElement.getFieldName()
<< " of non-array type "
@@ -227,7 +228,9 @@ Status ModifierPullAll::log(LogBuilder* logBuilder) const {
if (!logElement.ok()) {
return Status(ErrorCodes::InternalError,
str::stream() << "Could not append entry to $pullAll oplog entry: "
- << "set '" << _fieldRef.dottedField() << "' -> "
+ << "set '"
+ << _fieldRef.dottedField()
+ << "' -> "
<< _preparedState->pathFoundElement.toString());
}
return logBuilder->addToSets(logElement);
diff --git a/src/mongo/db/ops/modifier_push.cpp b/src/mongo/db/ops/modifier_push.cpp
index bf3886cbe24..7dc0f24e712 100644
--- a/src/mongo/db/ops/modifier_push.cpp
+++ b/src/mongo/db/ops/modifier_push.cpp
@@ -104,9 +104,9 @@ Status parseEachMode(ModifierPush::ModifierPushMode pushMode,
*eachElem = modExpr.embeddedObject()[kEach];
if (eachElem->type() != Array) {
return Status(ErrorCodes::BadValue,
- str::stream()
- << "The argument to $each in $push must be"
- " an array but it was of type: " << typeName(eachElem->type()));
+ str::stream() << "The argument to $each in $push must be"
+ " an array but it was of type: "
+ << typeName(eachElem->type()));
}
// There must be only one $each clause.
@@ -149,8 +149,8 @@ Status parseEachMode(ModifierPush::ModifierPushMode pushMode,
seenPosition = true;
} else if (!mongoutils::str::equals(elem.fieldName(), kEach)) {
return Status(ErrorCodes::BadValue,
- str::stream()
- << "Unrecognized clause in $push: " << elem.fieldNameStringData());
+ str::stream() << "Unrecognized clause in $push: "
+ << elem.fieldNameStringData());
}
}
@@ -214,7 +214,8 @@ Status ModifierPush::init(const BSONElement& modExpr, const Options& opts, bool*
if (foundDollar && foundCount > 1) {
return Status(ErrorCodes::BadValue,
str::stream() << "Too many positional (i.e. '$') elements found in path '"
- << _fieldRef.dottedField() << "'");
+ << _fieldRef.dottedField()
+ << "'");
}
//
@@ -264,7 +265,8 @@ Status ModifierPush::init(const BSONElement& modExpr, const Options& opts, bool*
if (_pushMode == PUSH_ALL) {
return Status(ErrorCodes::BadValue,
str::stream() << "$pushAll requires an array of values "
- "but was given type: " << typeName(modExpr.type()));
+ "but was given type: "
+ << typeName(modExpr.type()));
}
_val = modExpr;
@@ -379,9 +381,9 @@ Status ModifierPush::init(const BSONElement& modExpr, const Options& opts, bool*
for (size_t i = 0; i < sortField.numParts(); i++) {
if (sortField.getPart(i).size() == 0) {
return Status(ErrorCodes::BadValue,
- str::stream()
- << "The $sort field is a dotted field "
- "but has an empty part: " << sortField.dottedField());
+ str::stream() << "The $sort field is a dotted field "
+ "but has an empty part: "
+ << sortField.dottedField());
}
}
}
@@ -442,7 +444,9 @@ Status ModifierPush::prepare(mutablebson::Element root,
str::stream() << "The field '" << _fieldRef.dottedField() << "'"
<< " must be an array but is of type "
<< typeName(_preparedState->elemFound.getType())
- << " in document {" << idElem.toString() << "}");
+ << " in document {"
+ << idElem.toString()
+ << "}");
}
} else {
return status;
@@ -477,7 +481,8 @@ Status pushFirstElement(mb::Element& arrayElem,
if (!fromElem.ok()) {
return Status(ErrorCodes::InvalidLength,
str::stream() << "The specified position (" << appendPos << "/" << pos
- << ") is invalid based on the length ( " << arraySize
+ << ") is invalid based on the length ( "
+ << arraySize
<< ") of the array");
}
diff --git a/src/mongo/db/ops/modifier_push_sorter.h b/src/mongo/db/ops/modifier_push_sorter.h
index c942f4e5da3..6d795ec372d 100644
--- a/src/mongo/db/ops/modifier_push_sorter.h
+++ b/src/mongo/db/ops/modifier_push_sorter.h
@@ -28,9 +28,9 @@
#pragma once
-#include "mongo/db/jsobj.h"
#include "mongo/bson/mutable/document.h"
#include "mongo/bson/mutable/element.h"
+#include "mongo/db/jsobj.h"
namespace mongo {
diff --git a/src/mongo/db/ops/modifier_push_test.cpp b/src/mongo/db/ops/modifier_push_test.cpp
index e148ce5f6ef..6e37fc24d74 100644
--- a/src/mongo/db/ops/modifier_push_test.cpp
+++ b/src/mongo/db/ops/modifier_push_test.cpp
@@ -35,10 +35,10 @@
#include "mongo/base/status.h"
#include "mongo/base/string_data.h"
-#include "mongo/bson/ordering.h"
#include "mongo/bson/mutable/algorithm.h"
#include "mongo/bson/mutable/document.h"
#include "mongo/bson/mutable/mutable_bson_test_utils.h"
+#include "mongo/bson/ordering.h"
#include "mongo/db/jsobj.h"
#include "mongo/db/json.h"
#include "mongo/db/ops/log_builder.h"
@@ -659,13 +659,13 @@ TEST(SimpleObjMod, PrepareApplyNormal) {
}
TEST(SimpleObjMod, PrepareApplyDotted) {
- Document doc(fromjson(
- "{ _id : 1 , "
- " question : 'a', "
- " choices : { "
- " first : { choice : 'b' }, "
- " second : { choice : 'c' } }"
- "}"));
+ Document doc(
+ fromjson("{ _id : 1 , "
+ " question : 'a', "
+ " choices : { "
+ " first : { choice : 'b' }, "
+ " second : { choice : 'c' } }"
+ "}"));
Mod pushMod(fromjson("{$push: {'choices.first.votes': 1}}"));
ModifierInterface::ExecInfo execInfo;
@@ -676,13 +676,12 @@ TEST(SimpleObjMod, PrepareApplyDotted) {
ASSERT_OK(pushMod.apply());
ASSERT_FALSE(doc.isInPlaceModeEnabled());
- ASSERT_EQUALS(fromjson(
- "{ _id : 1 , "
- " question : 'a', "
- " choices : { "
- " first : { choice : 'b', votes: [1]}, "
- " second : { choice : 'c' } }"
- "}"),
+ ASSERT_EQUALS(fromjson("{ _id : 1 , "
+ " question : 'a', "
+ " choices : { "
+ " first : { choice : 'b', votes: [1]}, "
+ " second : { choice : 'c' } }"
+ "}"),
doc);
Document logDoc;
@@ -1059,8 +1058,9 @@ public:
arrBuilder.append(*it);
}
- _modObj = BSON("$push" << BSON("a" << BSON("$each" << arrBuilder.arr() << "$slice" << slice
- << "$sort" << sort)));
+ _modObj = BSON(
+ "$push" << BSON(
+ "a" << BSON("$each" << arrBuilder.arr() << "$slice" << slice << "$sort" << sort)));
ASSERT_OK(_mod.init(_modObj["$push"].embeddedObject().firstElement(),
ModifierInterface::Options::normal()));
diff --git a/src/mongo/db/ops/modifier_rename.cpp b/src/mongo/db/ops/modifier_rename.cpp
index 26dc2b23df9..c2935fb1906 100644
--- a/src/mongo/db/ops/modifier_rename.cpp
+++ b/src/mongo/db/ops/modifier_rename.cpp
@@ -29,8 +29,8 @@
#include "mongo/db/ops/modifier_rename.h"
#include "mongo/base/error_codes.h"
-#include "mongo/bson/mutable/document.h"
#include "mongo/bson/mutable/algorithm.h"
+#include "mongo/bson/mutable/document.h"
#include "mongo/db/ops/field_checker.h"
#include "mongo/db/ops/log_builder.h"
#include "mongo/db/ops/path_support.h"
@@ -95,15 +95,16 @@ Status ModifierRename::init(const BSONElement& modExpr, const Options& opts, boo
// Old restriction is that if the fields are the same then it is not allowed.
if (_fromFieldRef == _toFieldRef)
return Status(ErrorCodes::BadValue,
- str::stream()
- << "The source and target field for $rename must differ: " << modExpr);
+ str::stream() << "The source and target field for $rename must differ: "
+ << modExpr);
// TODO: Remove this restriction by allowing moving deeping from the 'from' path
// Old restriction is that if the to/from is on the same path it fails
if (_fromFieldRef.isPrefixOf(_toFieldRef) || _toFieldRef.isPrefixOf(_fromFieldRef)) {
return Status(ErrorCodes::BadValue,
str::stream() << "The source and target field for $rename must "
- "not be on the same path: " << modExpr);
+ "not be on the same path: "
+ << modExpr);
}
// TODO: We can remove this restriction as long as there is only one,
// or it is the same array -- should think on this a bit.
@@ -161,9 +162,11 @@ Status ModifierRename::prepare(mutablebson::Element root,
if (curr.getType() == Array)
return Status(ErrorCodes::BadValue,
str::stream() << "The source field cannot be an array element, '"
- << _fromFieldRef.dottedField() << "' in doc with "
+ << _fromFieldRef.dottedField()
+ << "' in doc with "
<< findElementNamed(root.leftChild(), "_id").toString()
- << " has an array field called '" << curr.getFieldName()
+ << " has an array field called '"
+ << curr.getFieldName()
<< "'");
curr = curr.parent();
}
@@ -191,9 +194,11 @@ Status ModifierRename::prepare(mutablebson::Element root,
if (curr.getType() == Array)
return Status(ErrorCodes::BadValue,
str::stream() << "The destination field cannot be an array element, '"
- << _fromFieldRef.dottedField() << "' in doc with "
+ << _fromFieldRef.dottedField()
+ << "' in doc with "
<< findElementNamed(root.leftChild(), "_id").toString()
- << " has an array field called '" << curr.getFieldName()
+ << " has an array field called '"
+ << curr.getFieldName()
<< "'");
curr = curr.parent();
}
diff --git a/src/mongo/db/ops/modifier_set.cpp b/src/mongo/db/ops/modifier_set.cpp
index c6966fae079..59f59c555ce 100644
--- a/src/mongo/db/ops/modifier_set.cpp
+++ b/src/mongo/db/ops/modifier_set.cpp
@@ -88,7 +88,8 @@ Status ModifierSet::init(const BSONElement& modExpr, const Options& opts, bool*
if (foundDollar && foundCount > 1) {
return Status(ErrorCodes::BadValue,
str::stream() << "Too many positional (i.e. '$') elements found in path '"
- << _fieldRef.dottedField() << "'");
+ << _fieldRef.dottedField()
+ << "'");
}
//
diff --git a/src/mongo/db/ops/modifier_unset.cpp b/src/mongo/db/ops/modifier_unset.cpp
index 673cbdb8d16..453b2d60d1c 100644
--- a/src/mongo/db/ops/modifier_unset.cpp
+++ b/src/mongo/db/ops/modifier_unset.cpp
@@ -83,7 +83,8 @@ Status ModifierUnset::init(const BSONElement& modExpr, const Options& opts, bool
if (foundDollar && foundCount > 1) {
return Status(ErrorCodes::BadValue,
str::stream() << "Too many positional (i.e. '$') elements found in path '"
- << _fieldRef.dottedField() << "'");
+ << _fieldRef.dottedField()
+ << "'");
}
diff --git a/src/mongo/db/ops/parsed_delete.cpp b/src/mongo/db/ops/parsed_delete.cpp
index 4e027390a79..b2f723e455e 100644
--- a/src/mongo/db/ops/parsed_delete.cpp
+++ b/src/mongo/db/ops/parsed_delete.cpp
@@ -35,8 +35,8 @@
#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/database.h"
#include "mongo/db/exec/delete.h"
-#include "mongo/db/ops/delete_request.h"
#include "mongo/db/matcher/extensions_callback_real.h"
+#include "mongo/db/ops/delete_request.h"
#include "mongo/db/query/canonical_query.h"
#include "mongo/db/query/get_executor.h"
#include "mongo/db/query/query_planner_common.h"
diff --git a/src/mongo/db/ops/parsed_update.h b/src/mongo/db/ops/parsed_update.h
index c9bb03edf9a..eabef19b483 100644
--- a/src/mongo/db/ops/parsed_update.h
+++ b/src/mongo/db/ops/parsed_update.h
@@ -30,9 +30,9 @@
#include "mongo/base/disallow_copying.h"
#include "mongo/base/status.h"
+#include "mongo/db/ops/update_driver.h"
#include "mongo/db/query/collation/collator_interface.h"
#include "mongo/db/query/plan_executor.h"
-#include "mongo/db/ops/update_driver.h"
namespace mongo {
diff --git a/src/mongo/db/ops/path_support.cpp b/src/mongo/db/ops/path_support.cpp
index e430c7d57cc..a95b700acd0 100644
--- a/src/mongo/db/ops/path_support.cpp
+++ b/src/mongo/db/ops/path_support.cpp
@@ -66,7 +66,8 @@ Status maybePadTo(mutablebson::Element* elemArray, size_t sizeRequired) {
if (toPad > kMaxPaddingAllowed) {
return Status(ErrorCodes::CannotBackfillArray,
mongoutils::str::stream() << "can't backfill more than "
- << kMaxPaddingAllowed << " elements");
+ << kMaxPaddingAllowed
+ << " elements");
}
for (size_t i = 0; i < toPad; i++) {
@@ -139,8 +140,10 @@ Status findLongestPrefix(const FieldRef& prefix,
*elemFound = prev;
return Status(ErrorCodes::PathNotViable,
mongoutils::str::stream() << "cannot use the part (" << prefix.getPart(i - 1)
- << " of " << prefix.dottedField()
- << ") to traverse the element ({" << curr.toString()
+ << " of "
+ << prefix.dottedField()
+ << ") to traverse the element ({"
+ << curr.toString()
<< "})");
} else if (curr.ok()) {
*idxFound = i - 1;
diff --git a/src/mongo/db/ops/path_support_test.cpp b/src/mongo/db/ops/path_support_test.cpp
index 01345564ccd..f1de975850f 100644
--- a/src/mongo/db/ops/path_support_test.cpp
+++ b/src/mongo/db/ops/path_support_test.cpp
@@ -537,7 +537,9 @@ static void assertContains(const EqualityMatches& equalities, const BSONObj& wra
}
if (!it->second->getData().valuesEqual(value)) {
FAIL(stream() << "Equality match at path \"" << path << "\" contains value "
- << it->second->getData() << ", not value " << value);
+ << it->second->getData()
+ << ", not value "
+ << value);
}
}
@@ -827,12 +829,17 @@ static void assertParent(const EqualityMatches& equalities,
StringData foundParentPath = path.dottedSubstring(0, parentPathPart);
if (foundParentPath != parentPath) {
FAIL(stream() << "Equality match parent at path \"" << foundParentPath
- << "\" does not match \"" << parentPath << "\"");
+ << "\" does not match \""
+ << parentPath
+ << "\"");
}
if (!parentEl.valuesEqual(value)) {
FAIL(stream() << "Equality match parent for \"" << pathStr << "\" at path \"" << parentPath
- << "\" contains value " << parentEl << ", not value " << value);
+ << "\" contains value "
+ << parentEl
+ << ", not value "
+ << value);
}
}
@@ -852,7 +859,8 @@ static void assertNoParent(const EqualityMatches& equalities, StringData pathStr
if (!parentEl.eoo()) {
StringData foundParentPath = path.dottedSubstring(0, parentPathPart);
FAIL(stream() << "Equality matches contained parent for \"" << pathStr << "\" at \""
- << foundParentPath << "\"");
+ << foundParentPath
+ << "\"");
}
}
diff --git a/src/mongo/db/ops/update.cpp b/src/mongo/db/ops/update.cpp
index d5b83ae666b..c808d9aab34 100644
--- a/src/mongo/db/ops/update.cpp
+++ b/src/mongo/db/ops/update.cpp
@@ -96,7 +96,8 @@ UpdateResult update(OperationContext* txn, Database* db, const UpdateRequest& re
if (userInitiatedWritesAndNotPrimary) {
uassertStatusOK(Status(ErrorCodes::NotMaster,
str::stream() << "Not primary while creating collection "
- << nsString.ns() << " during upsert"));
+ << nsString.ns()
+ << " during upsert"));
}
WriteUnitOfWork wuow(txn);
collection = db->createCollection(txn, nsString.ns(), CollectionOptions());
diff --git a/src/mongo/db/ops/update.h b/src/mongo/db/ops/update.h
index ff21054e25a..8ff64538a9d 100644
--- a/src/mongo/db/ops/update.h
+++ b/src/mongo/db/ops/update.h
@@ -30,8 +30,8 @@
#pragma once
-#include "mongo/db/jsobj.h"
#include "mongo/db/curop.h"
+#include "mongo/db/jsobj.h"
#include "mongo/db/ops/update_request.h"
#include "mongo/db/ops/update_result.h"
diff --git a/src/mongo/db/ops/update_driver.cpp b/src/mongo/db/ops/update_driver.cpp
index 19abae7b96f..fad283493cd 100644
--- a/src/mongo/db/ops/update_driver.cpp
+++ b/src/mongo/db/ops/update_driver.cpp
@@ -112,7 +112,9 @@ Status UpdateDriver::parse(const BSONObj& updateExpr, const bool multi) {
str::stream() << "Modifiers operate on fields but we found type "
<< typeName(outerModElem.type())
<< " instead. For example: {$mod: {<field>: ...}}"
- << " not {" << outerModElem.toString() << "}");
+ << " not {"
+ << outerModElem.toString()
+ << "}");
}
// Check whether there are indeed mods under this modifier.
@@ -120,7 +122,9 @@ Status UpdateDriver::parse(const BSONObj& updateExpr, const bool multi) {
return Status(ErrorCodes::FailedToParse,
str::stream() << "'" << outerModElem.fieldName()
<< "' is empty. You must specify a field like so: "
- "{" << outerModElem.fieldName() << ": {<field>: ...}}");
+ "{"
+ << outerModElem.fieldName()
+ << ": {<field>: ...}}");
}
BSONObjIterator innerIter(outerModElem.embeddedObject());
@@ -146,7 +150,9 @@ inline Status UpdateDriver::addAndParse(const modifiertable::ModifierType type,
if (elem.eoo()) {
return Status(ErrorCodes::FailedToParse,
str::stream() << "'" << elem.fieldName() << "' has no value in : " << elem
- << " which is not allowed for any $" << type << " mod.");
+ << " which is not allowed for any $"
+ << type
+ << " mod.");
}
unique_ptr<ModifierInterface> mod(modifiertable::makeUpdateMod(type));
@@ -275,7 +281,8 @@ Status UpdateDriver::update(StringData matchedField,
if (!targetFields->insert(execInfo.fieldRef[i], &other)) {
return Status(ErrorCodes::ConflictingUpdateOperators,
str::stream() << "Cannot update '" << other->dottedField()
- << "' and '" << execInfo.fieldRef[i]->dottedField()
+ << "' and '"
+ << execInfo.fieldRef[i]->dottedField()
<< "' at the same time");
}
@@ -371,7 +378,8 @@ BSONObj UpdateDriver::makeOplogEntryQuery(const BSONObj& doc, bool multi) const
} else {
uassert(16980,
str::stream() << "Multi-update operations require all documents to "
- "have an '_id' field. " << doc.toString(false, false),
+ "have an '_id' field. "
+ << doc.toString(false, false),
!multi);
return doc;
}
diff --git a/src/mongo/db/ops/update_lifecycle_impl.cpp b/src/mongo/db/ops/update_lifecycle_impl.cpp
index a5202948963..8f714519ea1 100644
--- a/src/mongo/db/ops/update_lifecycle_impl.cpp
+++ b/src/mongo/db/ops/update_lifecycle_impl.cpp
@@ -30,10 +30,10 @@
#include "mongo/db/ops/update_lifecycle_impl.h"
-#include "mongo/db/client.h"
+#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/database.h"
+#include "mongo/db/client.h"
#include "mongo/db/field_ref.h"
-#include "mongo/db/catalog/collection.h"
#include "mongo/db/s/collection_metadata.h"
#include "mongo/db/s/sharding_state.h"
diff --git a/src/mongo/db/ops/update_request.h b/src/mongo/db/ops/update_request.h
index 731c1195606..f6aa0e31d10 100644
--- a/src/mongo/db/ops/update_request.h
+++ b/src/mongo/db/ops/update_request.h
@@ -28,8 +28,8 @@
#pragma once
-#include "mongo/db/jsobj.h"
#include "mongo/db/curop.h"
+#include "mongo/db/jsobj.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/query/explain.h"
#include "mongo/util/mongoutils/str.h"
diff --git a/src/mongo/db/ops/update_result.h b/src/mongo/db/ops/update_result.h
index 9c1c27c5a93..2c3107e3ea1 100644
--- a/src/mongo/db/ops/update_result.h
+++ b/src/mongo/db/ops/update_result.h
@@ -28,8 +28,8 @@
#pragma once
-#include "mongo/db/jsobj.h"
#include "mongo/db/curop.h"
+#include "mongo/db/jsobj.h"
#include "mongo/db/namespace_string.h"
#include "mongo/util/mongoutils/str.h"
diff --git a/src/mongo/db/ops/write_ops_exec.cpp b/src/mongo/db/ops/write_ops_exec.cpp
index 82e712b39ab..5371736b7bd 100644
--- a/src/mongo/db/ops/write_ops_exec.cpp
+++ b/src/mongo/db/ops/write_ops_exec.cpp
@@ -209,8 +209,8 @@ bool handleError(OperationContext* txn,
<< demangleName(typeid(ex)));
}
- ShardingState::get(txn)
- ->onStaleShardVersion(txn, wholeOp.ns, staleConfigException->getVersionReceived());
+ ShardingState::get(txn)->onStaleShardVersion(
+ txn, wholeOp.ns, staleConfigException->getVersionReceived());
out->staleConfigException =
stdx::make_unique<SendStaleConfigException>(*staleConfigException);
return false;
@@ -230,7 +230,8 @@ static WriteResult::SingleResult createIndex(OperationContext* txn,
uassert(ErrorCodes::TypeMismatch,
str::stream() << "Expected \"ns\" field of index description to be a "
"string, "
- "but found a " << typeName(nsElement.type()),
+ "but found a "
+ << typeName(nsElement.type()),
nsElement.type() == String);
const NamespaceString ns(nsElement.valueStringData());
uassert(ErrorCodes::InvalidOptions,
diff --git a/src/mongo/db/ops/write_ops_parsers.cpp b/src/mongo/db/ops/write_ops_parsers.cpp
index 1eb3e8693d2..a4ade410010 100644
--- a/src/mongo/db/ops/write_ops_parsers.cpp
+++ b/src/mongo/db/ops/write_ops_parsers.cpp
@@ -50,22 +50,31 @@ void checkTypeInArray(BSONType expectedType,
const BSONElement& arrayElem) {
uassert(ErrorCodes::TypeMismatch,
str::stream() << "Wrong type for " << arrayElem.fieldNameStringData() << '['
- << elem.fieldNameStringData() << "]. Expected a "
- << typeName(expectedType) << ", got a " << typeName(elem.type()) << '.',
+ << elem.fieldNameStringData()
+ << "]. Expected a "
+ << typeName(expectedType)
+ << ", got a "
+ << typeName(elem.type())
+ << '.',
elem.type() == expectedType);
}
void checkType(BSONType expectedType, const BSONElement& elem) {
uassert(ErrorCodes::TypeMismatch,
str::stream() << "Wrong type for '" << elem.fieldNameStringData() << "'. Expected a "
- << typeName(expectedType) << ", got a " << typeName(elem.type()) << '.',
+ << typeName(expectedType)
+ << ", got a "
+ << typeName(elem.type())
+ << '.',
elem.type() == expectedType);
}
void checkOpCountForCommand(size_t numOps) {
uassert(ErrorCodes::InvalidLength,
str::stream() << "Write batch sizes must be between 1 and " << kMaxWriteBatchSize
- << ". Got " << numOps << " operations.",
+ << ". Got "
+ << numOps
+ << " operations.",
numOps != 0 && numOps <= kMaxWriteBatchSize);
}
@@ -108,7 +117,8 @@ void parseWriteCommand(StringData dbName,
"writeConcern", "maxTimeMS", "shardVersion"};
uassert(ErrorCodes::FailedToParse,
str::stream() << "Unknown option to " << cmd.firstElementFieldName()
- << " command: " << fieldName,
+ << " command: "
+ << fieldName,
std::find(ignoredFields.begin(), ignoredFields.end(), fieldName) !=
ignoredFields.end());
}
@@ -116,7 +126,8 @@ void parseWriteCommand(StringData dbName,
uassert(ErrorCodes::FailedToParse,
str::stream() << "The " << uniqueFieldName << " option is required to the "
- << cmd.firstElementFieldName() << " command.",
+ << cmd.firstElementFieldName()
+ << " command.",
haveUniqueField);
}
}
diff --git a/src/mongo/db/ops/write_ops_parsers.h b/src/mongo/db/ops/write_ops_parsers.h
index 526703fadd3..376fac81874 100644
--- a/src/mongo/db/ops/write_ops_parsers.h
+++ b/src/mongo/db/ops/write_ops_parsers.h
@@ -29,8 +29,8 @@
#pragma once
#include "mongo/db/jsobj.h"
-#include "mongo/util/net/message.h"
#include "mongo/db/ops/write_ops.h"
+#include "mongo/util/net/message.h"
namespace mongo {
diff --git a/src/mongo/db/ops/write_ops_parsers_test.cpp b/src/mongo/db/ops/write_ops_parsers_test.cpp
index 252479b4915..78eb0212609 100644
--- a/src/mongo/db/ops/write_ops_parsers_test.cpp
+++ b/src/mongo/db/ops/write_ops_parsers_test.cpp
@@ -39,7 +39,9 @@ TEST(CommandWriteOpsParsers, CommonFields_BypassDocumentValidation) {
for (BSONElement bypassDocumentValidation : BSON_ARRAY(true << false << 1 << 0 << 1.0 << 0.0)) {
auto cmd = BSON("insert"
<< "bar"
- << "documents" << BSON_ARRAY(BSONObj()) << "bypassDocumentValidation"
+ << "documents"
+ << BSON_ARRAY(BSONObj())
+ << "bypassDocumentValidation"
<< bypassDocumentValidation);
auto op = parseInsertCommand("foo", cmd);
ASSERT_EQ(op.bypassDocumentValidation, shouldBypassDocumentValidationForCommand(cmd));
@@ -50,7 +52,10 @@ TEST(CommandWriteOpsParsers, CommonFields_Ordered) {
for (bool ordered : {true, false}) {
auto cmd = BSON("insert"
<< "bar"
- << "documents" << BSON_ARRAY(BSONObj()) << "ordered" << ordered);
+ << "documents"
+ << BSON_ARRAY(BSONObj())
+ << "ordered"
+ << ordered);
auto op = parseInsertCommand("foo", cmd);
ASSERT_EQ(op.continueOnError, !ordered);
}
@@ -60,45 +65,55 @@ TEST(CommandWriteOpsParsers, CommonFields_IgnoredFields) {
// These flags are ignored, so there is nothing to check other than that this doesn't throw.
auto cmd = BSON("insert"
<< "bar"
- << "documents" << BSON_ARRAY(BSONObj()) << "maxTimeMS" << 1000 << "shardVersion"
- << BSONObj() << "writeConcern" << BSONObj());
+ << "documents"
+ << BSON_ARRAY(BSONObj())
+ << "maxTimeMS"
+ << 1000
+ << "shardVersion"
+ << BSONObj()
+ << "writeConcern"
+ << BSONObj());
parseInsertCommand("foo", cmd);
}
TEST(CommandWriteOpsParsers, GarbageFieldsAtTopLevel) {
auto cmd = BSON("insert"
<< "bar"
- << "documents" << BSON_ARRAY(BSONObj()) << "GARBAGE" << 1);
+ << "documents"
+ << BSON_ARRAY(BSONObj())
+ << "GARBAGE"
+ << 1);
ASSERT_THROWS_CODE(parseInsertCommand("foo", cmd), UserException, ErrorCodes::FailedToParse);
}
TEST(CommandWriteOpsParsers, GarbageFieldsInUpdateDoc) {
- auto cmd =
- BSON("update"
- << "bar"
- << "updates" << BSON_ARRAY("q" << BSONObj() << "u" << BSONObj() << "GARBAGE" << 1));
+ auto cmd = BSON("update"
+ << "bar"
+ << "updates"
+ << BSON_ARRAY("q" << BSONObj() << "u" << BSONObj() << "GARBAGE" << 1));
ASSERT_THROWS_CODE(parseInsertCommand("foo", cmd), UserException, ErrorCodes::FailedToParse);
}
TEST(CommandWriteOpsParsers, GarbageFieldsInDeleteDoc) {
auto cmd = BSON("delete"
<< "bar"
- << "deletes" << BSON_ARRAY("q" << BSONObj() << "limit" << 0 << "GARBAGE" << 1));
+ << "deletes"
+ << BSON_ARRAY("q" << BSONObj() << "limit" << 0 << "GARBAGE" << 1));
}
TEST(CommandWriteOpsParsers, BadCollationFieldInUpdateDoc) {
- auto cmd =
- BSON("update"
- << "bar"
- << "updates" << BSON_ARRAY("q" << BSONObj() << "u" << BSONObj() << "collation" << 1));
+ auto cmd = BSON("update"
+ << "bar"
+ << "updates"
+ << BSON_ARRAY("q" << BSONObj() << "u" << BSONObj() << "collation" << 1));
ASSERT_THROWS_CODE(parseInsertCommand("foo", cmd), UserException, ErrorCodes::FailedToParse);
}
TEST(CommandWriteOpsParsers, BadCollationFieldInDeleteDoc) {
- auto cmd =
- BSON("delete"
- << "bar"
- << "deletes" << BSON_ARRAY("q" << BSONObj() << "limit" << 0 << "collation" << 1));
+ auto cmd = BSON("delete"
+ << "bar"
+ << "deletes"
+ << BSON_ARRAY("q" << BSONObj() << "limit" << 0 << "collation" << 1));
ASSERT_THROWS_CODE(parseInsertCommand("foo", cmd), UserException, ErrorCodes::FailedToParse);
}
@@ -144,8 +159,11 @@ TEST(CommandWriteOpsParsers, Update) {
for (bool multi : {false, true}) {
auto cmd = BSON("update" << ns.coll() << "updates"
<< BSON_ARRAY(BSON("q" << query << "u" << update << "collation"
- << collation << "upsert" << upsert
- << "multi" << multi)));
+ << collation
+ << "upsert"
+ << upsert
+ << "multi"
+ << multi)));
auto op = parseUpdateCommand(ns.db(), cmd);
ASSERT_EQ(op.ns.ns(), ns.ns());
ASSERT(!op.bypassDocumentValidation);
@@ -166,9 +184,10 @@ TEST(CommandWriteOpsParsers, Remove) {
const BSONObj collation = BSON("locale"
<< "en_US");
for (bool multi : {false, true}) {
- auto cmd = BSON("delete" << ns.coll() << "deletes"
- << BSON_ARRAY(BSON("q" << query << "collation" << collation
- << "limit" << (multi ? 0 : 1))));
+ auto cmd =
+ BSON("delete" << ns.coll() << "deletes"
+ << BSON_ARRAY(BSON("q" << query << "collation" << collation << "limit"
+ << (multi ? 0 : 1))));
auto op = parseDeleteCommand(ns.db(), cmd);
ASSERT_EQ(op.ns.ns(), ns.ns());
ASSERT(!op.bypassDocumentValidation);
@@ -185,7 +204,8 @@ TEST(CommandWriteOpsParsers, RemoveErrorsWithBadLimit) {
for (BSONElement limit : BSON_ARRAY(-1 << 2 << 0.5)) {
auto cmd = BSON("delete"
<< "bar"
- << "deletes" << BSON_ARRAY("q" << BSONObj() << "limit" << limit));
+ << "deletes"
+ << BSON_ARRAY("q" << BSONObj() << "limit" << limit));
ASSERT_THROWS_CODE(
parseInsertCommand("foo", cmd), UserException, ErrorCodes::FailedToParse);
}