diff options
author | Drew Paroski <drew.paroski@mongodb.com> | 2021-03-13 00:34:32 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-03-13 06:02:52 +0000 |
commit | a90fee27ae85894ae6e4522251fe0ea35ef473c7 (patch) | |
tree | 45ee5bc229551060300bf1750f672336cfffbede /src/mongo/db | |
parent | c9e91f213a7f28bf466ca7103fe9552f4b993e79 (diff) | |
download | mongo-a90fee27ae85894ae6e4522251fe0ea35ef473c7.tar.gz |
SERVER-54332 [SBE] $elemMatch with object filter returns no documents
Diffstat (limited to 'src/mongo/db')
-rw-r--r-- | src/mongo/db/query/sbe_stage_builder_filter.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/mongo/db/query/sbe_stage_builder_filter.cpp b/src/mongo/db/query/sbe_stage_builder_filter.cpp index ec290338a93..1f4d65eb4ba 100644 --- a/src/mongo/db/query/sbe_stage_builder_filter.cpp +++ b/src/mongo/db/query/sbe_stage_builder_filter.cpp @@ -912,7 +912,15 @@ EvalExprStagePair elemMatchMakePredicate(MatchExpressionVisitorContext* context, context->planNodeId, context->frameIdGenerator); - return {traverseSlot, std::move(traverseStage)}; + // There are some cases where 'traverseOutputSlot' gets set to Nothing when TraverseStage + // doesn't match anything. One example of when this happens is when innerBranch->getNext() + // returns EOF every time it is called by TraverseStage. In these cases $elemMatch should return + // false instead of Nothing. + auto projectExpr = makeFunction("fillEmpty", + sbe::makeE<sbe::EVariable>(traverseSlot), + context->stateHelper.makeState(false)); + + return {std::move(projectExpr), std::move(traverseStage)}; } /** |