diff --git a/src/graph/planner/ngql/FetchVerticesPlanner.cpp b/src/graph/planner/ngql/FetchVerticesPlanner.cpp index 2e017817363..8e94bc12247 100644 --- a/src/graph/planner/ngql/FetchVerticesPlanner.cpp +++ b/src/graph/planner/ngql/FetchVerticesPlanner.cpp @@ -14,7 +14,7 @@ namespace graph { std::unique_ptr FetchVerticesPlanner::buildVertexProps( const ExpressionProps::TagIDPropsMap& propsMap) { if (propsMap.empty()) { - return nullptr; + return std::make_unique(); } auto vertexProps = std::make_unique(propsMap.size()); auto fun = [](auto& tag) { diff --git a/src/parser/parser.yy b/src/parser/parser.yy index 6d4c02565d4..2783049482d 100644 --- a/src/parser/parser.yy +++ b/src/parser/parser.yy @@ -2916,6 +2916,9 @@ insert_vertex_sentence : KW_INSERT KW_VERTEX opt_if_not_exists opt_ignore_existed_index vertex_tag_list KW_VALUES vertex_row_list { $$ = new InsertVerticesSentence($5, $7, $3, $4); } + | KW_INSERT KW_VERTEX opt_if_not_exists opt_ignore_existed_index KW_VALUES vertex_row_list { + $$ = new InsertVerticesSentence(new VertexTagList(), $6, $3, $4); + } ; vertex_tag_list diff --git a/tests/tck/features/insert/insertVertexOnly.feature b/tests/tck/features/insert/insertVertexOnly.feature new file mode 100644 index 00000000000..f8eb92ec5f6 --- /dev/null +++ b/tests/tck/features/insert/insertVertexOnly.feature @@ -0,0 +1,40 @@ +# Copyright (c) 2021 vesoft inc. All rights reserved. +# +# This source code is licensed under Apache 2.0 License. +Feature: insert vertex without tag + + Background: Background name + Given an empty graph + And create a space with following options: + | partition_num | 9 | + | replica_factor | 1 | + | vid_type | int64 | + + Scenario: insert vertex only + Given having executed: + """ + CREATE EDGE e(); + """ + And wait 6 seconds + When executing query: + """ + INSERT VERTEX VALUES 1:(),2:(),3:(); + INSERT EDGE e() VALUES 1->2:(),2->3:(); + """ + Then the execution should be successful + When executing query: + """ + GO 2 STEP FROM 1 OVER e yield e._dst AS dst; + """ + Then the result should be, in any order: + | dst | + | 3 | + When executing query: + """ + FETCH PROP ON * 1,2 yield vertex AS v; + """ + Then the result should be, in any order, with relax comparison: + | v | + | (1) | + | (2) | + Then drop the used space