Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
nevermore3 committed Sep 22, 2021
1 parent be7db0d commit c75a184
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/graph/validator/FetchVerticesValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ Status FetchVerticesValidator::validateYield(YieldClause *yield) {
auto pool = qctx_->objPool();
bool noYield = false;
if (yield == nullptr) {
// version 3.0: return Status::SemanticError("No YIELD Clause");
// compatible with previous versions
// TODO: compatible with previous version, this will be deprecated in version 3.0.
auto *yieldColumns = new YieldColumns();
auto *vertex = new YieldColumn(VertexExpression::make(pool), "vertices_");
yieldColumns->addColumn(vertex);
Expand Down
4 changes: 4 additions & 0 deletions src/graph/validator/MatchValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,10 @@ Status MatchValidator::validateReturn(MatchReturn *ret,
}
if (ret->returnItems()->columns()) {
for (auto *column : ret->returnItems()->columns()->columns()) {
if (ExpressionUtils::hasAny(column->expr(),
{Expression::Kind::kVertex, Expression::Kind::kEdge})) {
return Status::SemanticError("illegal return clause `%s'", column->toString().c_str());
}
columns->addColumn(column->clone().release());
}
}
Expand Down
20 changes: 20 additions & 0 deletions src/graph/validator/test/MatchValidatorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,26 @@ TEST_F(MatchValidatorTest, validateAlias) {
EXPECT_EQ(std::string(result.message()),
"SemanticError: Path `p' does not have the type attribute");
}
{
std::string query = "MATCH (v:person) return id(vertex)";
auto result = checkResult(query);
EXPECT_EQ(std::string(result.message()), "SemanticError: illegal return clause `id(VERTEX)'");
}
{
std::string query = "MATCH (v:person) return vertex as a";
auto result = checkResult(query);
EXPECT_EQ(std::string(result.message()), "SemanticError: illegal return clause `VERTEX AS a'");
}
{
std::string query = "MATCH (v:person)-[e]-(v2) return src(edge)";
auto result = checkResult(query);
EXPECT_EQ(std::string(result.message()), "SemanticError: illegal return clause `src(EDGE)'");
}
{
std::string query = "MATCH (v:person)-[e]-(v2) return edge as b";
auto result = checkResult(query);
EXPECT_EQ(std::string(result.message()), "SemanticError: illegal return clause `EDGE AS b'");
}
}

} // namespace graph
Expand Down
6 changes: 6 additions & 0 deletions src/graph/validator/test/QueryValidatorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,12 @@ TEST_F(QueryValidatorTest, GoInvalid) {
auto result = checkResult(query);
EXPECT_EQ(std::string(result.message()), "SemanticError: Duplicate Column Name : `id'");
}
{
std::string query = "GO FROM id(vertex) OVER * ";
auto result = checkResult(query);
EXPECT_EQ(std::string(result.message()),
"SemanticError: `id(VERTEX)' is not an evaluable expression.");
}
}

TEST_F(QueryValidatorTest, Limit) {
Expand Down

0 comments on commit c75a184

Please sign in to comment.