diff options
author | Mihai Andrei <mihai.andrei@10gen.com> | 2020-07-02 19:20:55 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-07-02 23:49:49 +0000 |
commit | 639c8e665ed9eb55cea88c700885d8b01727e6d5 (patch) | |
tree | 94af30fa920be31cd8ce7b06189e312460b2a023 /src/mongo/db/matcher | |
parent | bca920ba961a95e58fa2f40d80844817ad1489d8 (diff) | |
download | mongo-639c8e665ed9eb55cea88c700885d8b01727e6d5.tar.gz |
Revert "SERVER-48781 Introduce 'DocumentValidationErrorExtraInfo' and shell support for document validation errors"
This reverts commit 0ab6e8fb4d26b7bbe22d483dbe7850e64013447c.
Diffstat (limited to 'src/mongo/db/matcher')
-rw-r--r-- | src/mongo/db/matcher/doc_validation_error.cpp | 21 | ||||
-rw-r--r-- | src/mongo/db/matcher/doc_validation_error.h | 17 |
2 files changed, 4 insertions, 34 deletions
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<const ErrorExtraInfo> 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<DocumentValidationFailureInfo>(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<const ErrorExtraInfo> 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 |