Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix_delete_validate #5645

Merged
merged 1 commit into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
nevermore3 marked this conversation as resolved.
Show resolved Hide resolved
"""
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
Loading