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 empty prop of tag and edge #505

Merged
merged 7 commits into from
Jul 9, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Support empty property
  • Loading branch information
laura-ding committed Jul 6, 2019
commit 1bf424abec1058e6438d6894992d08a85fc75d9d
32 changes: 28 additions & 4 deletions src/parser/parser.yy
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ vertex_tag_list
;

vertex_tag_item
: name_label {
: name_label L_PAREN R_PAREN{
$$ = new VertexTagItem($1);
}
| name_label L_PAREN prop_list R_PAREN {
Expand Down Expand Up @@ -862,7 +862,10 @@ vertex_row_list
;

vertex_row_item
: vid COLON L_PAREN value_list R_PAREN {
: vid COLON L_PAREN R_PAREN {
$$ = new VertexRowItem($1, new ValueList());
}
| vid COLON L_PAREN value_list R_PAREN {
$$ = new VertexRowItem($1, $4);
}
;
Expand All @@ -882,13 +885,28 @@ value_list
;

insert_edge_sentence
: KW_INSERT KW_EDGE name_label L_PAREN prop_list R_PAREN KW_VALUES edge_row_list {
: KW_INSERT KW_EDGE name_label L_PAREN R_PAREN KW_VALUES edge_row_list {
auto sentence = new InsertEdgeSentence();
sentence->setEdge($3);
sentence->setProps(new PropertyList());
sentence->setRows($7);
$$ = sentence;
}
| KW_INSERT KW_EDGE name_label L_PAREN prop_list R_PAREN KW_VALUES edge_row_list {
auto sentence = new InsertEdgeSentence();
sentence->setEdge($3);
sentence->setProps($5);
sentence->setRows($8);
$$ = sentence;
}
| KW_INSERT KW_EDGE KW_NO KW_OVERWRITE name_label L_PAREN R_PAREN KW_VALUES edge_row_list {
auto sentence = new InsertEdgeSentence();
sentence->setOverwrite(false);
sentence->setEdge($5);
sentence->setProps(new PropertyList());
sentence->setRows($9);
$$ = sentence;
}
| KW_INSERT KW_EDGE KW_NO KW_OVERWRITE name_label L_PAREN prop_list R_PAREN KW_VALUES edge_row_list {
auto sentence = new InsertEdgeSentence();
sentence->setOverwrite(false);
Expand All @@ -911,9 +929,15 @@ edge_row_list
;

edge_row_item
: vid R_ARROW vid COLON L_PAREN value_list R_PAREN {
: vid R_ARROW vid COLON L_PAREN R_PAREN {
$$ = new EdgeRowItem($1, $3, new ValueList());
}
| vid R_ARROW vid COLON L_PAREN value_list R_PAREN {
$$ = new EdgeRowItem($1, $3, $6);
}
| vid R_ARROW INTEGER AT INTEGER COLON L_PAREN R_PAREN {
$$ = new EdgeRowItem($1, $3, $5, new ValueList());
}
| vid R_ARROW vid AT rank COLON L_PAREN value_list R_PAREN {
$$ = new EdgeRowItem($1, $3, $5, $8);
}
Expand Down
38 changes: 38 additions & 0 deletions src/parser/test/ParserTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ TEST(Parser, TagOperation) {
auto result = parser.parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
// Test empty prop
{
GQLParser parser;
std::string query = "CREATE TAG person()";
auto result = parser.parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
{
GQLParser parser;
std::string query = "CREATE TAG man(name string, age int, "
Expand Down Expand Up @@ -211,6 +218,13 @@ TEST(Parser, EdgeOperation) {
auto result = parser.parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
// Test empty prop
{
GQLParser parser;
std::string query = "CREATE EDGE e1()";
auto result = parser.parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
{
GQLParser parser;
std::string query = "CREATE EDGE man(name string, age int, "
Expand Down Expand Up @@ -371,6 +385,14 @@ TEST(Parser, InsertVertex) {
auto result = parser.parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
// Test insert empty value
{
GQLParser parser;
std::string query = "INSERT VERTEX person() "
"VALUES 12345:()";
auto result = parser.parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
}

TEST(Parser, UpdateVertex) {
Expand Down Expand Up @@ -428,6 +450,14 @@ TEST(Parser, InsertEdge) {
auto result = parser.parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
// Test insert empty value
{
GQLParser parser;
std::string query = "INSERT EDGE transfer() "
"VALUES 12345->54321@1537408527:()";
auto result = parser.parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
{
GQLParser parser;
std::string query = "INSERT EDGE NO OVERWRITE transfer(amount, time) "
Expand All @@ -449,6 +479,14 @@ TEST(Parser, InsertEdge) {
auto result = parser.parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
// Test insert empty value
{
GQLParser parser;
std::string query = "INSERT EDGE NO OVERWRITE transfer() "
"VALUES 12345->54321@1537408527:()";
auto result = parser.parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
}

TEST(Parser, UpdateEdge) {
Expand Down