summaryrefslogtreecommitdiff
path: root/src/mongo/db/matcher/expression_parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/matcher/expression_parser.cpp')
-rw-r--r--src/mongo/db/matcher/expression_parser.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/mongo/db/matcher/expression_parser.cpp b/src/mongo/db/matcher/expression_parser.cpp
index 327d00262fe..a06e07b82d7 100644
--- a/src/mongo/db/matcher/expression_parser.cpp
+++ b/src/mongo/db/matcher/expression_parser.cpp
@@ -338,8 +338,12 @@ StatusWithMatchExpression parseWhere(StringData name,
if ((allowedFeatures & MatchExpressionParser::AllowedFeatures::kJavascript) == 0u) {
return {Status(ErrorCodes::BadValue, "$where is not allowed in this context")};
}
+ if (currentLevel == DocumentParseLevel::kUserSubDocument) {
+ return {
+ Status(ErrorCodes::BadValue, "$where can only be applied to the top-level document")};
+ }
- return extensionsCallback->parseWhere(elem);
+ return extensionsCallback->parseWhere(expCtx, elem);
}
StatusWithMatchExpression parseText(StringData name,