From 3bfaed65d23bca62e9b678cca73e43b556ae985a Mon Sep 17 00:00:00 2001 From: "kyle.cao" <kyle.cao@vesoft.com> Date: Fri, 23 Apr 2021 18:01:29 +0800 Subject: [PATCH] enhance FindVisitor (#975) --- src/validator/test/YieldValidatorTest.cpp | 2 +- src/visitor/FindVisitor.inl | 4 ++++ tests/tck/features/go/GO.IntVid.feature | 2 +- tests/tck/features/go/GO.feature | 2 +- tests/tck/features/yield/yield.IntVid.feature | 2 +- tests/tck/features/yield/yield.feature | 2 +- 6 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/validator/test/YieldValidatorTest.cpp b/src/validator/test/YieldValidatorTest.cpp index 68775e43..4036448b 100644 --- a/src/validator/test/YieldValidatorTest.cpp +++ b/src/validator/test/YieldValidatorTest.cpp @@ -464,7 +464,7 @@ TEST_F(YieldValidatorTest, Error) { auto query = var + "YIELD like.start"; auto result = checkResult(query); EXPECT_EQ(std::string(result.message()), - "SemanticError: Not supported expression `like.start' for props deduction."); + "SemanticError: Invalid label identifiers: like"); } } diff --git a/src/visitor/FindVisitor.inl b/src/visitor/FindVisitor.inl index bb8217c0..d5fda21a 100644 --- a/src/visitor/FindVisitor.inl +++ b/src/visitor/FindVisitor.inl @@ -210,6 +210,10 @@ void FindVisitor<T>::visit(LabelExpression* expr) { template <typename T> void FindVisitor<T>::visit(LabelAttributeExpression *expr) { findInCurrentExpr(expr); + if (!needFindAll_ && found_) return; + expr->left()->accept(this); + if (!needFindAll_ && found_) return; + expr->right()->accept(this); } template <typename T> diff --git a/tests/tck/features/go/GO.IntVid.feature b/tests/tck/features/go/GO.IntVid.feature index 341c9e02..87847f39 100644 --- a/tests/tck/features/go/GO.IntVid.feature +++ b/tests/tck/features/go/GO.IntVid.feature @@ -348,7 +348,7 @@ Feature: IntegerVid Go Sentence """ YIELD serve.start_year, like.likeness, serve._type, like._type """ - Then a SemanticError should be raised at runtime: Not supported expression `serve.start_year' for props deduction. + Then a SemanticError should be raised at runtime: Invalid label identifiers: serve When executing query: """ GO FROM hash("Russell Westbrook") OVER serve, like REVERSELY diff --git a/tests/tck/features/go/GO.feature b/tests/tck/features/go/GO.feature index dd1ed529..ede7c04e 100644 --- a/tests/tck/features/go/GO.feature +++ b/tests/tck/features/go/GO.feature @@ -371,7 +371,7 @@ Feature: Go Sentence """ YIELD serve.start_year, like.likeness, serve._type, like._type """ - Then a SemanticError should be raised at runtime: Not supported expression `serve.start_year' for props deduction. + Then a SemanticError should be raised at runtime: Invalid label identifiers: serve When executing query: """ GO FROM "Russell Westbrook" OVER serve, like REVERSELY diff --git a/tests/tck/features/yield/yield.IntVid.feature b/tests/tck/features/yield/yield.IntVid.feature index 348b3d46..207a235d 100644 --- a/tests/tck/features/yield/yield.IntVid.feature +++ b/tests/tck/features/yield/yield.IntVid.feature @@ -308,7 +308,7 @@ Feature: Yield Sentence """ $var = GO FROM hash("Boris Diaw") OVER serve YIELD $^.player.name AS name, serve.start_year AS start, $$.team.name AS team;YIELD a.team """ - Then a SemanticError should be raised at runtime: Not supported expression `a.team' for props deduction. + Then a SemanticError should be raised at runtime: Invalid label identifiers: a When executing query: """ $var = GO FROM hash("Boris Diaw") OVER like YIELD $-.abc diff --git a/tests/tck/features/yield/yield.feature b/tests/tck/features/yield/yield.feature index ec598631..eb2ae104 100644 --- a/tests/tck/features/yield/yield.feature +++ b/tests/tck/features/yield/yield.feature @@ -308,7 +308,7 @@ Feature: Yield Sentence """ $var = GO FROM "Boris Diaw" OVER serve YIELD $^.player.name AS name, serve.start_year AS start, $$.team.name AS team;YIELD a.team """ - Then a SemanticError should be raised at runtime: Not supported expression `a.team' for props deduction. + Then a SemanticError should be raised at runtime: Invalid label identifiers: a When executing query: """ $var = GO FROM "Boris Diaw" OVER like YIELD $-.abc -- GitLab