Skip to content

Commit

Permalink
fix aliases in with after unwind. (#5016)
Browse files Browse the repository at this point in the history
  • Loading branch information
xtcyclist authored Dec 7, 2022
1 parent c3ee460 commit de02384
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/graph/validator/MatchValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,13 @@ Status MatchValidator::validateImpl() {
NG_RETURN_IF_ERROR(validateFilter(withClause->where()->filter(), *whereClauseCtx));
withClauseCtx->where = std::move(whereClauseCtx);
}

// A with pass all named aliases to the next query part.
aliasesAvailable = withClauseCtx->aliasesGenerated;
if (withClause->returnItems()->allNamedAliases()) {
aliasesAvailable.insert(withClauseCtx->aliasesGenerated.begin(),
withClauseCtx->aliasesGenerated.end());
} else {
aliasesAvailable = withClauseCtx->aliasesGenerated;
}
cypherCtx_->queryParts.back().boundary = std::move(withClauseCtx);
cypherCtx_->queryParts.emplace_back();
cypherCtx_->queryParts.back().aliasesAvailable = aliasesAvailable;
Expand Down
13 changes: 13 additions & 0 deletions tests/tck/features/match/With.feature
Original file line number Diff line number Diff line change
Expand Up @@ -374,3 +374,16 @@ Feature: With clause
Then the result should be, in any order:
| e.edgeProp_1_0 |
| NULL |

Scenario: with wildcard after unwind
When executing query:
"""
match p = (v0)-[e0]->(v1) where id(v0) in ["Tim Duncan"] unwind v0 as uv0 with * return e0 limit 5;
"""
Then the result should be, in any order:
| e0 |
| [:serve "Tim Duncan"->"Spurs" @0 {end_year: 2016, start_year: 1997}] |
| [:teammate "Tim Duncan"->"LaMarcus Aldridge" @0 {end_year: 2016, start_year: 2015}] |
| [:teammate "Tim Duncan"->"Tony Parker" @0 {end_year: 2016, start_year: 2001}] |
| [:like "Tim Duncan"->"Tony Parker" @0 {likeness: 95}] |
| [:teammate "Tim Duncan"->"Danny Green" @0 {end_year: 2016, start_year: 2010}] |

0 comments on commit de02384

Please sign in to comment.