From 32bcea9f7e55780a354e772850c34861c5973fb3 Mon Sep 17 00:00:00 2001 From: nebula-bots <88429921+nebula-bots@users.noreply.github.com> Date: Wed, 7 Dec 2022 17:50:30 +0800 Subject: [PATCH] fix aliases in with after unwind. (#1863) Co-authored-by: Cheng Xuntao <7731943+xtcyclist@users.noreply.github.com> --- src/graph/validator/MatchValidator.cpp | 8 ++++++-- tests/tck/features/match/With.feature | 13 +++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/graph/validator/MatchValidator.cpp b/src/graph/validator/MatchValidator.cpp index 2db7fa3bd68..f77394a24cd 100644 --- a/src/graph/validator/MatchValidator.cpp +++ b/src/graph/validator/MatchValidator.cpp @@ -100,9 +100,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; diff --git a/tests/tck/features/match/With.feature b/tests/tck/features/match/With.feature index 9f76a59e9b7..895853de8ba 100644 --- a/tests/tck/features/match/With.feature +++ b/tests/tck/features/match/With.feature @@ -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}] |