diff options
author | Nick Zolnierz <nicholas.zolnierz@mongodb.com> | 2019-02-25 10:14:09 -0500 |
---|---|---|
committer | Nick Zolnierz <nicholas.zolnierz@mongodb.com> | 2019-03-01 10:02:45 -0500 |
commit | adf8b17dd18bd0332a935e27eace73fc825982a3 (patch) | |
tree | e6c69c7d9afa991f5b6414d125b8d981d55a77d0 /src/mongo/db/matcher | |
parent | ea8c9655768b0d482f71a44c1760600d8319bf61 (diff) | |
download | mongo-adf8b17dd18bd0332a935e27eace73fc825982a3.tar.gz |
SERVER-39233 Add the ability to modify the RHS element of a parsed MatchExpression
Diffstat (limited to 'src/mongo/db/matcher')
-rw-r--r-- | src/mongo/db/matcher/expression.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/matcher/expression.h | 2 | ||||
-rw-r--r-- | src/mongo/db/matcher/expression_leaf.h | 8 | ||||
-rw-r--r-- | src/mongo/db/matcher/schema/encrypt_schema_types.h | 7 |
4 files changed, 14 insertions, 9 deletions
diff --git a/src/mongo/db/matcher/expression.cpp b/src/mongo/db/matcher/expression.cpp index b3117dcb208..35bee13f151 100644 --- a/src/mongo/db/matcher/expression.cpp +++ b/src/mongo/db/matcher/expression.cpp @@ -45,9 +45,9 @@ using std::string; MatchExpression::MatchExpression(MatchType type) : _matchType(type) {} string MatchExpression::toString() const { - StringBuilder buf; - debugString(buf, 0); - return buf.str(); + BSONObjBuilder bob; + serialize(&bob); + return bob.obj().toString(); } void MatchExpression::_debugAddSpace(StringBuilder& debug, int level) const { diff --git a/src/mongo/db/matcher/expression.h b/src/mongo/db/matcher/expression.h index f10dd8c5abd..02db8946ef4 100644 --- a/src/mongo/db/matcher/expression.h +++ b/src/mongo/db/matcher/expression.h @@ -103,8 +103,6 @@ public: TEXT, // Expressions that are only created internally - INTERNAL_2DSPHERE_KEY_IN_REGION, - INTERNAL_2D_KEY_IN_REGION, INTERNAL_2D_POINT_IN_ANNULUS, // Used to represent an expression language equality in a match expression tree, since $eq diff --git a/src/mongo/db/matcher/expression_leaf.h b/src/mongo/db/matcher/expression_leaf.h index 8da9948044b..cfe18e771a6 100644 --- a/src/mongo/db/matcher/expression_leaf.h +++ b/src/mongo/db/matcher/expression_leaf.h @@ -119,6 +119,14 @@ public: return _rhs; } + /** + * Replaces the RHS element of this expression. The caller is responsible for ensuring that the + * BSONObj backing 'elem' outlives this MatchExpression. + */ + void setData(BSONElement elem) { + _rhs = elem; + } + const CollatorInterface* getCollator() const { return _collator; } diff --git a/src/mongo/db/matcher/schema/encrypt_schema_types.h b/src/mongo/db/matcher/schema/encrypt_schema_types.h index 1b8fabaabc4..043d58ac935 100644 --- a/src/mongo/db/matcher/schema/encrypt_schema_types.h +++ b/src/mongo/db/matcher/schema/encrypt_schema_types.h @@ -126,14 +126,13 @@ public: MONGO_UNREACHABLE; } + EncryptSchemaAnyType() = default; + EncryptSchemaAnyType(BSONElement element) : _element(element) {} + void serializeToBSON(StringData fieldName, BSONObjBuilder* builder) const { builder->appendAs(_element, fieldName); } - void setElement(const BSONElement& element) { - _element = element; - } - private: BSONElement _element; }; |