Skip to content

Commit

Permalink
Fix aliases not pass to next query parts.
Browse files Browse the repository at this point in the history
  • Loading branch information
CPWstatic committed Dec 23, 2021
1 parent 620fd06 commit e5c2101
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/graph/validator/MatchValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,22 @@ Status MatchValidator::validateImpl() {
for (size_t j = 0; j < matchClause->path()->pathSize(); ++j) {
NG_RETURN_IF_ERROR(validatePath(matchClause->path()->path(j), *matchClauseCtx));
}

// Available aliases include the aliases pass from the with/unwind
// And previous aliases are all available to next match
auto aliasesTmp = matchClauseCtx->aliasesGenerated;
aliasesAvailable.merge(aliasesTmp);

if (matchClause->where() != nullptr) {
auto whereClauseCtx = getContext<WhereClauseContext>();
whereClauseCtx->aliasesAvailable = matchClauseCtx->aliasesGenerated;
whereClauseCtx->aliasesAvailable = aliasesAvailable;
NG_RETURN_IF_ERROR(validateFilter(matchClause->where()->filter(), *whereClauseCtx));
matchClauseCtx->where = std::move(whereClauseCtx);
}

// Copy the aliases without delete the origins.
auto aliasesTmp = matchClauseCtx->aliasesGenerated;
aliasesTmp = matchClauseCtx->aliasesGenerated;
cypherCtx_->queryParts.back().aliasesGenerated.merge(aliasesTmp);
aliasesAvailable = cypherCtx_->queryParts.back().aliasesGenerated;
cypherCtx_->queryParts.back().matchs.emplace_back(std::move(matchClauseCtx));

break;
Expand All @@ -62,7 +67,7 @@ Status MatchValidator::validateImpl() {
unwindClauseCtx->aliasesAvailable = aliasesAvailable;
NG_RETURN_IF_ERROR(validateUnwind(unwindClause, *unwindClauseCtx));

// An unwind bypass all available aliases.
// An unwind pass all available aliases.
aliasesAvailable.insert(unwindClauseCtx->aliasesGenerated.begin(),
unwindClauseCtx->aliasesGenerated.end());
cypherCtx_->queryParts.back().boundary = std::move(unwindClauseCtx);
Expand All @@ -85,6 +90,7 @@ Status MatchValidator::validateImpl() {
withClauseCtx->where = std::move(whereClauseCtx);
}

// A with pass all named aliases to the next query part.
aliasesAvailable = withClauseCtx->aliasesGenerated;
cypherCtx_->queryParts.back().boundary = std::move(withClauseCtx);
cypherCtx_->queryParts.emplace_back();
Expand Down

0 comments on commit e5c2101

Please sign in to comment.