From 639c8e665ed9eb55cea88c700885d8b01727e6d5 Mon Sep 17 00:00:00 2001 From: Mihai Andrei Date: Thu, 2 Jul 2020 19:20:55 -0400 Subject: Revert "SERVER-48781 Introduce 'DocumentValidationErrorExtraInfo' and shell support for document validation errors" This reverts commit 0ab6e8fb4d26b7bbe22d483dbe7850e64013447c. --- src/mongo/db/matcher/doc_validation_error.cpp | 21 +++------------------ src/mongo/db/matcher/doc_validation_error.h | 17 +---------------- 2 files changed, 4 insertions(+), 34 deletions(-) (limited to 'src/mongo/db/matcher') diff --git a/src/mongo/db/matcher/doc_validation_error.cpp b/src/mongo/db/matcher/doc_validation_error.cpp index 4018443dbd4..b81846d5297 100644 --- a/src/mongo/db/matcher/doc_validation_error.cpp +++ b/src/mongo/db/matcher/doc_validation_error.cpp @@ -29,16 +29,14 @@ #include "mongo/platform/basic.h" -#include "mongo/base/init.h" #include "mongo/bson/bsonobjbuilder.h" #include "mongo/db/matcher/doc_validation_error.h" #include "mongo/db/matcher/expression_visitor.h" #include "mongo/db/matcher/match_expression_walker.h" namespace mongo::doc_validation_error { -namespace { -MONGO_INIT_REGISTER_ERROR_EXTRA_INFO(DocumentValidationFailureInfo); +namespace { /** * Enumerated type which describes whether an error should be described normally or in an * inverted sense when in a negated context. More precisely, when a MatchExpression fails to match a @@ -203,6 +201,7 @@ private: class ValidationErrorPostVisitor final : public MatchExpressionConstVisitor { public: ValidationErrorPostVisitor(ValidationErrorContext* context) : _context(context) {} + void visit(const AlwaysFalseMatchExpression* expr) final {} void visit(const AlwaysTrueMatchExpression* expr) final {} void visit(const AndMatchExpression* expr) final {} @@ -271,20 +270,6 @@ private: } // namespace -std::shared_ptr DocumentValidationFailureInfo::parse(const BSONObj& obj) { - auto errInfo = obj["errInfo"]; - uassert(4878100, - "DocumentValidationFailureInfo must have a field 'errInfo' of type object", - errInfo.type() == BSONType::Object); - return std::make_shared(errInfo.embeddedObject()); -} - -void DocumentValidationFailureInfo::serialize(BSONObjBuilder* bob) const { - bob->append("errInfo", _details); -} -const BSONObj& DocumentValidationFailureInfo::getDetails() const { - return _details; -} BSONObj generateError(const MatchExpression& validatorExpr, const BSONObj& doc) { BSONMatchableDocument matchableDoc(doc); ValidationErrorContext context; @@ -296,4 +281,4 @@ BSONObj generateError(const MatchExpression& validatorExpr, const BSONObj& doc) return BSONObj(); } -} // namespace mongo::doc_validation_error +} // namespace mongo::doc_validation_error \ No newline at end of file diff --git a/src/mongo/db/matcher/doc_validation_error.h b/src/mongo/db/matcher/doc_validation_error.h index ae632080179..30d29be8516 100644 --- a/src/mongo/db/matcher/doc_validation_error.h +++ b/src/mongo/db/matcher/doc_validation_error.h @@ -29,29 +29,14 @@ #pragma once -#include "mongo/base/error_extra_info.h" #include "mongo/db/matcher/expression.h" namespace mongo::doc_validation_error { -/** - * Represents information about a document validation error. - */ -class DocumentValidationFailureInfo final : public ErrorExtraInfo { -public: - static constexpr auto code = ErrorCodes::DocumentValidationFailure; - static std::shared_ptr parse(const BSONObj& obj); - explicit DocumentValidationFailureInfo(const BSONObj& err) : _details(err.getOwned()) {} - const BSONObj& getDetails() const; - void serialize(BSONObjBuilder* bob) const override; - -private: - BSONObj _details; -}; - /** * Given a pointer to a MatchExpression corresponding to a collection's validator expression and a * reference to a BSONObj corresponding to the document that failed to match against the validator * expression, returns a BSONObj that describes why 'doc' failed to match against 'validatorExpr'. */ BSONObj generateError(const MatchExpression& validatorExpr, const BSONObj& doc); + } // namespace mongo::doc_validation_error \ No newline at end of file -- cgit v1.2.1