summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/projection_parser.cpp
diff options
context:
space:
mode:
authorIan Boros <ian.boros@mongodb.com>2019-12-06 22:02:41 +0000
committerevergreen <evergreen@mongodb.com>2019-12-06 22:02:41 +0000
commit3bfcdd40ebcfa9786947213e47bf148655bab666 (patch)
tree4b2fd4de12b3c58183b48e458f04ff9556bc72bd /src/mongo/db/query/projection_parser.cpp
parentc4a5310c8037c075cde7a0a1a32a7f00bfc19746 (diff)
downloadmongo-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.cpp25
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.