diff options
author | Minji <minjikim0202@gmail.com> | 2018-06-18 15:03:24 -0400 |
---|---|---|
committer | Minji <minjikim0202@gmail.com> | 2018-06-29 13:33:23 -0400 |
commit | 77d35b732b4aa312ba7dd3505dd90fbfe9b6753e (patch) | |
tree | b9fcd89b7ebd001aaf9c37398a7014ffdca0362e /src/mongo/db/update/update_driver.cpp | |
parent | a3f0ad233bab0f49ae19bbc14468c4b600ec794e (diff) | |
download | mongo-77d35b732b4aa312ba7dd3505dd90fbfe9b6753e.tar.gz |
SERVER-32348 Make UpdateDriver::parse() throw an exception instead of returning error Status
Diffstat (limited to 'src/mongo/db/update/update_driver.cpp')
-rw-r--r-- | src/mongo/db/update/update_driver.cpp | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/mongo/db/update/update_driver.cpp b/src/mongo/db/update/update_driver.cpp index d8b824316cb..761f914be83 100644 --- a/src/mongo/db/update/update_driver.cpp +++ b/src/mongo/db/update/update_driver.cpp @@ -149,7 +149,7 @@ bool parseUpdateExpression( UpdateDriver::UpdateDriver(const boost::intrusive_ptr<ExpressionContext>& expCtx) : _expCtx(expCtx) {} -Status UpdateDriver::parse( +void UpdateDriver::parse( const BSONObj& updateExpr, const std::map<StringData, std::unique_ptr<ExpressionWithPlaceholder>>& arrayFilters, const bool multi) { @@ -157,16 +157,14 @@ Status UpdateDriver::parse( // Check if the update expression is a full object replacement. if (isDocReplacement(updateExpr)) { - if (multi) { - return Status(ErrorCodes::FailedToParse, "multi update only works with $ operators"); - } + uassert(ErrorCodes::FailedToParse, "multi update only works with $ operators", !multi); _root = stdx::make_unique<ObjectReplaceNode>(updateExpr); // Register the fact that this driver will only do full object replacements. _replacementMode = true; - return Status::OK(); + return; } // Register the fact that this driver is not doing a full object replacement. @@ -178,20 +176,16 @@ Status UpdateDriver::parse( // we parse $v and check its value for compatibility. BSONElement updateSemanticsElement = updateExpr[LogBuilder::kUpdateSemanticsFieldName]; if (updateSemanticsElement) { - if (!_fromOplogApplication) { - return {ErrorCodes::FailedToParse, "The $v update field is only recognized internally"}; - } - auto statusWithUpdateSemantics = updateSemanticsFromElement(updateSemanticsElement); - if (!statusWithUpdateSemantics.isOK()) { - return statusWithUpdateSemantics.getStatus(); - } + uassert(ErrorCodes::FailedToParse, + "The $v update field is only recognized internally", + _fromOplogApplication); + + uassertStatusOK(updateSemanticsFromElement(updateSemanticsElement)); } auto root = stdx::make_unique<UpdateObjectNode>(); _positional = parseUpdateExpression(updateExpr, root.get(), _expCtx, arrayFilters); _root = std::move(root); - - return Status::OK(); } Status UpdateDriver::populateDocumentWithQueryFields(OperationContext* opCtx, |