diff options
author | Ian Boros <ian.boros@mongodb.com> | 2019-12-06 22:02:41 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-12-06 22:02:41 +0000 |
commit | 3bfcdd40ebcfa9786947213e47bf148655bab666 (patch) | |
tree | 4b2fd4de12b3c58183b48e458f04ff9556bc72bd /src/mongo/db/query/projection_parser.cpp | |
parent | c4a5310c8037c075cde7a0a1a32a7f00bfc19746 (diff) | |
download | mongo-3bfcdd40ebcfa9786947213e47bf148655bab666.tar.gz |
SERVER-40687 stricter checking on positional operator field
Diffstat (limited to 'src/mongo/db/query/projection_parser.cpp')
-rw-r--r-- | src/mongo/db/query/projection_parser.cpp | 25 |
1 files changed, 0 insertions, 25 deletions
diff --git a/src/mongo/db/query/projection_parser.cpp b/src/mongo/db/query/projection_parser.cpp index decea04b326..b9d3e118493 100644 --- a/src/mongo/db/query/projection_parser.cpp +++ b/src/mongo/db/query/projection_parser.cpp @@ -218,27 +218,6 @@ PositionalProjectionLocation findFirstPositionalOperator(StringData fullPath) { return boost::none; } -bool hasPositionalOperatorMatch(const MatchExpression* const query, StringData matchField) { - if (query->getCategory() == MatchExpression::MatchCategory::kLogical) { - for (unsigned int i = 0; i < query->numChildren(); ++i) { - if (hasPositionalOperatorMatch(query->getChild(i), matchField)) { - return true; - } - } - } else { - StringData queryPath = query->path(); - // We have to make a distinction between match expressions that are - // initialized with an empty field/path name "" and match expressions - // for which the path is not meaningful (eg. $where). - if (!queryPath.rawData()) { - return false; - } - StringData pathPrefix = str::before(queryPath, '.'); - return pathPrefix == matchField; - } - return false; -} - bool isPrefixOf(StringData first, StringData second) { if (first.size() >= second.size()) { return false; @@ -453,10 +432,6 @@ void parseInclusion(ParseContext* ctx, StringData matchField = fullPathToParent ? fullPathToParent->front() : str::before(elem.fieldNameStringData(), '.'); uassert(51050, "Projections with a positional operator require a matcher", ctx->query); - uassert(31277, - str::stream() << "Positional projection '" << elem.fieldName() << "' does not " - << "match the query document.", - hasPositionalOperatorMatch(ctx->query, matchField)); // Check that the path does not end with ".$." which can be interpreted as the // positional projection. |