diff --git a/src/validator/MutateValidator.cpp b/src/validator/MutateValidator.cpp index f67003ba7..ce1f95b6a 100644 --- a/src/validator/MutateValidator.cpp +++ b/src/validator/MutateValidator.cpp @@ -263,10 +263,10 @@ Status DeleteVerticesValidator::validateImpl() { vidRef_ = sentence->vertices()->ref(); auto type = deduceExprType(vidRef_); NG_RETURN_IF_ERROR(type); - if (type.value() != Value::Type::STRING) { + if (type.value() != vidType_) { std::stringstream ss; - ss << "The vid should be string type, " - << "but input is `" << type.value() << "'"; + ss << "The vid `" << vidRef_->toString() << "' should be type of `" << vidType_ + << "', but was`" << type.value() << "'"; return Status::SemanticError(ss.str()); } } else { diff --git a/tests/tck/features/delete/DeleteEdge.IntVid.feature b/tests/tck/features/delete/DeleteEdge.IntVid.feature index c72403bdb..b76964d1f 100644 --- a/tests/tck/features/delete/DeleteEdge.IntVid.feature +++ b/tests/tck/features/delete/DeleteEdge.IntVid.feature @@ -135,3 +135,57 @@ Feature: Delete int vid of edge | $^.person.name | friend.intimacy | friend._dst | | "Zhangsan" | 50 | "Jack" | Then drop the used space + + Scenario: delete edges use pipe + Given load "nba_int_vid" csv data to a new space + # test delete with pipe wrong vid type + When executing query: + """ + GO FROM hash("Boris Diaw") OVER like YIELD (string)like._src as id | DELETE EDGE like $-.id->$-.id + """ + Then a ExecutionError should be raised at runtime: Wrong srcId type `STRING`, value + # delete with pipe, get result by go + When executing query: + """ + GO FROM hash("Boris Diaw") OVER like + """ + Then the result should be, in any order, and the columns 0 should be hashed: + | like._dst | + | "Tony Parker" | + | "Tim Duncan" | + When executing query: + """ + GO FROM hash("Boris Diaw") OVER like + YIELD like._src as src, like._dst as dst, like._rank as rank + | DELETE EDGE like $-.src->$-.dst @ $-.rank + """ + Then the execution should be successful + When executing query: + """ + GO FROM hash("Boris Diaw") OVER like + """ + Then the result should be, in any order: + | like._dst | + # delete with var, get result by go + When executing query: + """ + GO FROM hash("Russell Westbrook") OVER like + """ + Then the result should be, in any order, and the columns 0 should be hashed: + | like._dst | + | "Paul George" | + | "James Harden" | + When executing query: + """ + $var = GO FROM hash("Russell Westbrook") OVER like YIELD + like._src as src, like._dst as dst, like._rank as rank; + DELETE EDGE like $var.src -> $var.dst @ $var.rank + """ + Then the execution should be successful + When executing query: + """ + GO FROM hash("Russell Westbrook") OVER like + """ + Then the result should be, in any order: + | like._dst | + And drop the used space diff --git a/tests/tck/features/delete/DeleteEdge.feature b/tests/tck/features/delete/DeleteEdge.feature index 68a1043d6..164d51141 100644 --- a/tests/tck/features/delete/DeleteEdge.feature +++ b/tests/tck/features/delete/DeleteEdge.feature @@ -136,7 +136,7 @@ Feature: Delete string vid of edge | "Zhangsan" | 50 | "Jack" | Then drop the used space - Scenario: delete edges for 2.0 syntax + Scenario: delete edges use pipe Given load "nba" csv data to a new space # test delete with pipe wrong vid type When executing query: diff --git a/tests/tck/features/delete/DeleteVertex.IntVid.feature b/tests/tck/features/delete/DeleteVertex.IntVid.feature index 0a5b08d71..0771b4bf7 100644 --- a/tests/tck/features/delete/DeleteVertex.IntVid.feature +++ b/tests/tck/features/delete/DeleteVertex.IntVid.feature @@ -196,4 +196,118 @@ Feature: Delete int vid of vertex """ Then the result should be, in any order: | VertexID | player.name | player.age | + + Scenario: delete int vertex by pipe successed + Given load "nba_int_vid" csv data to a new space + # test delete with pipe wrong vid type + When executing query: + """ + GO FROM hash("Boris Diaw") OVER like YIELD (string)like._src as id | DELETE VERTEX $-.id + """ + Then a SemanticError should be raised at runtime: + # delete with pipe, get result by go + When executing query: + """ + GO FROM hash("Boris Diaw") OVER like + """ + Then the result should be, in any order, and the columns 0 should be hashed: + | like._dst | + | "Tony Parker" | + | "Tim Duncan" | + When executing query: + """ + GO FROM hash("Tony Parker") OVER like + """ + Then the result should be, in any order, and the columns 0 should be hashed: + | like._dst | + | "LaMarcus Aldridge" | + | "Manu Ginobili" | + | "Tim Duncan" | + When executing query: + """ + GO FROM hash("Tim Duncan") OVER like + """ + Then the result should be, in any order, and the columns 0 should be hashed: + | like._dst | + | "Tony Parker" | + | "Manu Ginobili" | + When executing query: + """ + GO FROM hash("Boris Diaw") OVER like YIELD like._dst as id | DELETE VERTEX $-.id + """ + Then the execution should be successful + When executing query: + """ + GO FROM hash("Boris Diaw") OVER like + """ + Then the result should be, in any order: + | like._dst | + When executing query: + """ + GO FROM hash("Tony Parker") OVER like + """ + Then the result should be, in any order: + | like._dst | + When executing query: + """ + GO FROM hash("Tim Duncan") OVER like + """ + Then the result should be, in any order: + | like._dst | + + Scenario: delete with pipe failed, because of the wrong vid type + When executing query: + """ + USE nba_int_vid;YIELD "Tom" as id | DELETE VERTEX $-.id; + """ + Then a SemanticError should be raised at runtime: The vid `$-.id' should be type of `INT', but was`STRING' + Then drop the used space + + Scenario: delete with var, get result by go + Given load "nba_int_vid" csv data to a new space + When executing query: + """ + GO FROM hash("Russell Westbrook") OVER like + """ + Then the result should be, in any order, and the columns 0 should be hashed: + | like._dst | + | "Paul George" | + | "James Harden" | + When executing query: + """ + GO FROM hash("Paul George") OVER like + """ + Then the result should be, in any order, and the columns 0 should be hashed: + | like._dst | + | "Russell Westbrook" | + When executing query: + """ + GO FROM hash("James Harden") OVER like + """ + Then the result should be, in any order, and the columns 0 should be hashed: + | like._dst | + | "Russell Westbrook" | + When executing query: + """ + $var = GO FROM hash("Russell Westbrook") OVER like YIELD like._dst as id; DELETE VERTEX $var.id + """ + Then the execution should be successful + When executing query: + """ + GO FROM hash("Russell Westbrook") OVER like + """ + Then the result should be, in any order: + | like._dst | + When executing query: + """ + GO FROM hash("Paul George") OVER like + """ + Then the result should be, in any order: + | like._dst | + When executing query: + """ + GO FROM hash("Russell Westbrook") OVER like + """ + Then the result should be, in any order: + | like._dst | Then drop the used space diff --git a/tests/tck/features/delete/DeleteVertex.feature b/tests/tck/features/delete/DeleteVertex.feature index d6f79d013..7622c5d30 100644 --- a/tests/tck/features/delete/DeleteVertex.feature +++ b/tests/tck/features/delete/DeleteVertex.feature @@ -198,14 +198,14 @@ Feature: Delete string vid of vertex | VertexID | player.name | player.age | Then drop the used space - Scenario: delete vertex by pipe + Scenario: delete string vertex by pipe Given load "nba" csv data to a new space # test delete with pipe wrong vid type When executing query: """ GO FROM "Boris Diaw" OVER like YIELD like._type as id | DELETE VERTEX $-.id """ - Then a SemanticError should be raised at runtime: The vid should be string type, but input is `INT' + Then a SemanticError should be raised at runtime: # delete with pipe, get result by go When executing query: """ @@ -255,7 +255,9 @@ Feature: Delete string vid of vertex """ Then the result should be, in any order: | like._dst | - # delete with var, get result by go + + Scenario: delete with var, get result by go + Given load "nba" csv data to a new space When executing query: """ GO FROM "Russell Westbrook" OVER like