Skip to content

Commit

Permalink
Improve unreserved keywords feature (#418)
Browse files Browse the repository at this point in the history
  • Loading branch information
ayyt authored and dutor committed May 31, 2019
1 parent e41c6ef commit b24ca04
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 15 deletions.
46 changes: 46 additions & 0 deletions src/graph/test/SchemaTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,52 @@ TEST_F(SchemaTest, metaCommunication) {
};
ASSERT_TRUE(verifyResult(resp, expected));
}
{
cpp2::ExecutionResponse resp;
std::string query = "CREATE TAG man(name string, email string, "
"age int, gender string, row_timestamp timestamp)";
auto code = client->execute(query, resp);
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code);
}
sleep(FLAGS_load_data_interval_secs + 1);
{
cpp2::ExecutionResponse resp;
std::string query = "DESCRIBE TAG man";
auto code = client->execute(query, resp);
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code);

std::vector<uniform_tuple_t<std::string, 2>> expected{
{"name", "string"},
{"email", "string"},
{"age", "int"},
{"gender", "string"},
{"row_timestamp", "timestamp"},
};
ASSERT_TRUE(verifyResult(resp, expected));
}
{
cpp2::ExecutionResponse resp;
std::string query = "CREATE TAG upper(name string, EMAIL string, "
"age int, gender string, row_timestamp timestamp)";
auto code = client->execute(query, resp);
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code);
}
sleep(FLAGS_load_data_interval_secs + 1);
{
cpp2::ExecutionResponse resp;
std::string query = "DESCRIBE TAG upper";
auto code = client->execute(query, resp);
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code);

std::vector<uniform_tuple_t<std::string, 2>> expected{
{"name", "string"},
{"email", "string"},
{"age", "int"},
{"gender", "string"},
{"row_timestamp", "timestamp"},
};
ASSERT_TRUE(verifyResult(resp, expected));
}
{
cpp2::ExecutionResponse resp;
std::string query = "CREATE TAG account(id int, balance double)";
Expand Down
30 changes: 15 additions & 15 deletions src/parser/parser.yy
Original file line number Diff line number Diff line change
Expand Up @@ -174,21 +174,21 @@ name_label
;

unreserved_keyword
: KW_SPACE { $$ = new std::string("SPACE"); }
| KW_HOSTS { $$ = new std::string("HOSTS"); }
| KW_SPACES { $$ = new std::string("SPACES"); }
| KW_FIRSTNAME { $$ = new std::string("FIRSTNAME"); }
| KW_LASTNAME { $$ = new std::string("LASTNAME"); }
| KW_EMAIL { $$ = new std::string("EMAIL"); }
| KW_PHONE { $$ = new std::string("PHONE"); }
| KW_USER { $$ = new std::string("USER"); }
| KW_USERS { $$ = new std::string("USERS"); }
| KW_PASSWORD { $$ = new std::string("PASSWORD"); }
| KW_ROLE { $$ = new std::string("ROLE"); }
| KW_ROLES { $$ = new std::string("ROLES"); }
| KW_GOD { $$ = new std::string("GOD"); }
| KW_ADMIN { $$ = new std::string("ADMIN"); }
| KW_GUEST { $$ = new std::string("GUEST"); }
: KW_SPACE { $$ = new std::string("space"); }
| KW_HOSTS { $$ = new std::string("hosts"); }
| KW_SPACES { $$ = new std::string("spaces"); }
| KW_FIRSTNAME { $$ = new std::string("firstname"); }
| KW_LASTNAME { $$ = new std::string("lastname"); }
| KW_EMAIL { $$ = new std::string("email"); }
| KW_PHONE { $$ = new std::string("phone"); }
| KW_USER { $$ = new std::string("user"); }
| KW_USERS { $$ = new std::string("users"); }
| KW_PASSWORD { $$ = new std::string("password"); }
| KW_ROLE { $$ = new std::string("role"); }
| KW_ROLES { $$ = new std::string("roles"); }
| KW_GOD { $$ = new std::string("god"); }
| KW_ADMIN { $$ = new std::string("admin"); }
| KW_GUEST { $$ = new std::string("guest"); }
;

primary_expression
Expand Down

0 comments on commit b24ca04

Please sign in to comment.