summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/expression.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/pipeline/expression.cpp')
-rw-r--r--src/mongo/db/pipeline/expression.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/mongo/db/pipeline/expression.cpp b/src/mongo/db/pipeline/expression.cpp
index eb20fc65a39..42f95c7746f 100644
--- a/src/mongo/db/pipeline/expression.cpp
+++ b/src/mongo/db/pipeline/expression.cpp
@@ -2363,11 +2363,14 @@ intrusive_ptr<Expression> ExpressionLet::parse(ExpressionContext* const expCtx,
auto& inPtr = children.emplace_back(nullptr);
std::vector<boost::intrusive_ptr<Expression>>::size_type index = 0;
+ std::vector<Variables::Id> orderedVariableIds;
for (auto&& varElem : varsObj) {
const string varName = varElem.fieldName();
Variables::validateNameForUserWrite(varName);
Variables::Id id = vpsSub.defineVariable(varName);
+ orderedVariableIds.push_back(id);
+
vars.emplace(id, NameAndExpression{varName, children[index]}); // only has outer vars
++index;
}
@@ -2375,14 +2378,17 @@ intrusive_ptr<Expression> ExpressionLet::parse(ExpressionContext* const expCtx,
// parse "in"
inPtr = parseOperand(expCtx, inElem, vpsSub); // has our vars
- return new ExpressionLet(expCtx, std::move(vars), std::move(children));
+ return new ExpressionLet(
+ expCtx, std::move(vars), std::move(children), std::move(orderedVariableIds));
}
ExpressionLet::ExpressionLet(ExpressionContext* const expCtx,
VariableMap&& vars,
- std::vector<boost::intrusive_ptr<Expression>> children)
+ std::vector<boost::intrusive_ptr<Expression>> children,
+ std::vector<Variables::Id> orderedVariableIds)
: Expression(expCtx, std::move(children)),
_variables(std::move(vars)),
+ _orderedVariableIds(std::move(orderedVariableIds)),
_subExpression(_children.back()) {}
intrusive_ptr<Expression> ExpressionLet::optimize() {