diff options
Diffstat (limited to 'src/mongo/db/query/projection_parser.cpp')
| -rw-r--r-- | src/mongo/db/query/projection_parser.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/mongo/db/query/projection_parser.cpp b/src/mongo/db/query/projection_parser.cpp index 85ada560ccc..3495f99f8f2 100644 --- a/src/mongo/db/query/projection_parser.cpp +++ b/src/mongo/db/query/projection_parser.cpp @@ -510,7 +510,16 @@ void parseSubObject(ParseContext* ctx, // It was likely intended to be an expression. Check if it's a valid field path or not to // confirm. try { - FieldPath fp(obj.firstElementFieldNameStringData()); + const auto elementFieldName = obj.firstElementFieldNameStringData(); + if (!hasPositionalOperator(elementFieldName)) { + FieldPath fp(elementFieldName); + } else { + // The 'FieldPath' parser doesn't take positional operators into account, but those + // are valid path projections so trim it off for this validation. + StringData pathWithoutPositionalOperator = + elementFieldName.substr(0, elementFieldName.size() - 2); + FieldPath fp(pathWithoutPositionalOperator); + } } catch (const DBException&) { uasserted(31325, str::stream() |
