Skip to content

Commit

Permalink
fix_delete_validate (#5645)
Browse files Browse the repository at this point in the history
add test case
  • Loading branch information
nevermore3 committed Jul 19, 2023
1 parent 8765f55 commit 0ef388a
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/graph/validator/MutateValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,10 @@ Status DeleteVerticesValidator::validateImpl() {
} else {
auto vIds = sentence->vertices()->vidList();
for (auto vId : vIds) {
if (!ExpressionUtils::isEvaluableExpr(vId, qctx_)) {
return Status::SemanticError("`%s' is not an evaluable expression.",
vId->toString().c_str());
}
auto idStatus = SchemaUtil::toVertexID(vId, vidType_);
NG_RETURN_IF_ERROR(idStatus);
vertices_.emplace_back(std::move(idStatus).value());
Expand Down Expand Up @@ -464,6 +468,10 @@ Status DeleteTagsValidator::validateImpl() {
} else {
auto vIds = sentence->vertices()->vidList();
for (auto vId : vIds) {
if (!ExpressionUtils::isEvaluableExpr(vId, qctx_)) {
return Status::SemanticError("`%s' is not an evaluable expression.",
vId->toString().c_str());
}
auto idStatus = SchemaUtil::toVertexID(vId, vidType_);
NG_RETURN_IF_ERROR(idStatus);
vertices_.emplace_back(std::move(idStatus).value());
Expand Down Expand Up @@ -551,6 +559,14 @@ Status DeleteEdgesValidator::buildEdgeKeyRef(const std::vector<EdgeKey *> &edgeK
for (auto &edgeKey : edgeKeys) {
Row row;
storage::cpp2::EdgeKey key;
if (!ExpressionUtils::isEvaluableExpr(edgeKey->srcid(), qctx_)) {
return Status::SemanticError("`%s' is not an evaluable expression.",
edgeKey->srcid()->toString().c_str());
}
if (!ExpressionUtils::isEvaluableExpr(edgeKey->dstid(), qctx_)) {
return Status::SemanticError("`%s' is not an evaluable expression.",
edgeKey->dstid()->toString().c_str());
}
auto srcIdStatus = SchemaUtil::toVertexID(edgeKey->srcid(), vidType_);
NG_RETURN_IF_ERROR(srcIdStatus);
auto dstIdStatus = SchemaUtil::toVertexID(edgeKey->dstid(), vidType_);
Expand Down
6 changes: 6 additions & 0 deletions tests/tck/features/delete/DeleteEdge.IntVid.feature
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,12 @@ Feature: Delete int vid of edge
| like._dst |
| "Tony Parker" |
| "Tim Duncan" |
When executing query:
"""
GO FROM hash("Boris Diaw") OVER like YIELD edge as e
| DELETE EDGE like src($-.e)->dst($-.e)
"""
Then a SemanticError should be raised at runtime: `src($-.e)' is not an evaluable expression.
When executing query:
"""
GO FROM hash("Boris Diaw") OVER like
Expand Down
6 changes: 6 additions & 0 deletions tests/tck/features/delete/DeleteEdge.feature
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,12 @@ Feature: Delete string vid of edge
| like._dst |
| "Tony Parker" |
| "Tim Duncan" |
When executing query:
"""
GO FROM "Boris Diaw" OVER like YIELD edge as e
| DELETE EDGE like src($-.e)->dst($-.e)
"""
Then a SemanticError should be raised at runtime: `src($-.e)' is not an evaluable expression.
When executing query:
"""
GO FROM "Boris Diaw" OVER like
Expand Down
5 changes: 5 additions & 0 deletions tests/tck/features/delete/DeleteTag.IntVid.feature
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@ Feature: Delete int vid of tag
| team.name |
| "Spurs" |
# delete one tag
When executing query:
"""
GO FROM hash("Tim Duncan") OVER serve YIELD edge as e | DELETE TAG team FROM src($-.e)
"""
Then a SemanticError should be raised at runtime: `src($-.e)' is not an evaluable expression.
When executing query:
"""
GO FROM hash("Tim Duncan") OVER serve YIELD serve._dst as id | DELETE TAG team FROM $-.id
Expand Down
5 changes: 5 additions & 0 deletions tests/tck/features/delete/DeleteTag.feature
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@ Feature: Delete string vid of tag
| team.name |
| "Spurs" |
# delete one tag
When executing query:
"""
GO FROM "Tim Duncan" OVER serve YIELD edge as e | DELETE TAG team FROM src($-.e)
"""
Then a SemanticError should be raised at runtime: `src($-.e)' is not an evaluable expression.
When executing query:
"""
GO FROM "Tim Duncan" OVER serve YIELD serve._dst as id | DELETE TAG team FROM $-.id
Expand Down
5 changes: 5 additions & 0 deletions tests/tck/features/delete/DeleteVertex.IntVid.feature
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,11 @@ Feature: Delete int vid of vertex
| like._dst |
| "Tony Parker" |
| "Manu Ginobili" |
When executing query:
"""
GO FROM hash("Boris Diaw") OVER like YIELD edge as e | DELETE VERTEX src($-.e) WITH EDGE
"""
Then a SemanticError should be raised at runtime: `src($-.e)' is not an evaluable expression.
When executing query:
"""
GO FROM hash("Boris Diaw") OVER like YIELD like._dst as id | DELETE VERTEX $-.id WITH EDGE
Expand Down
5 changes: 5 additions & 0 deletions tests/tck/features/delete/DeleteVertex.feature
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,11 @@ Feature: Delete string vid of vertex
| like._dst |
| "Tony Parker" |
| "Manu Ginobili" |
When executing query:
"""
GO FROM "Boris Diaw" OVER like YIELD edge as e | DELETE VERTEX src($-.e) WITH EDGE
"""
Then a SemanticError should be raised at runtime: `src($-.e)' is not an evaluable expression.
When executing query:
"""
GO FROM "Boris Diaw" OVER like YIELD like._dst as id | DELETE VERTEX $-.id WITH EDGE
Expand Down
5 changes: 5 additions & 0 deletions tests/tck/features/delete/DeleteVertexWithoutEdge.feature
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ Feature: delete vertex without edge
| a | id |
| 2 | 1 |
| 3 | 1 |
When executing query:
"""
GO FROM 1 OVER e YIELD edge as e1 | DELETE VERTEX dst($-.e1)
"""
Then a SemanticError should be raised at runtime: `dst($-.e1)' is not an evaluable expression.
When executing query:
"""
DELETE VERTEX 1;
Expand Down

0 comments on commit 0ef388a

Please sign in to comment.