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

Schema support mixed Chinese and English #3440

Merged
merged 4 commits into from
Dec 13, 2021
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
4 changes: 2 additions & 2 deletions src/parser/parser.yy
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ static constexpr size_t kCommentLengthLimit = 256;
%token <boolval> BOOL
%token <intval> INTEGER
%token <doubleval> DOUBLE
%token <strval> STRING VARIABLE LABEL IPV4 CHINESE_LABEL
%token <strval> STRING VARIABLE LABEL IPV4 UTF8_LABEL

%type <strval> name_label unreserved_keyword predicate_name
%type <expr> expression
Expand Down Expand Up @@ -406,7 +406,7 @@ static constexpr size_t kCommentLengthLimit = 256;

name_label
: LABEL { $$ = $1; }
| CHINESE_LABEL { $$ = $1; }
| UTF8_LABEL { $$ = $1; }
heroicNeZha marked this conversation as resolved.
Show resolved Hide resolved
| unreserved_keyword { $$ = $1; }
;

Expand Down
9 changes: 6 additions & 3 deletions src/parser/scanner.lex
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ U [\x80-\xbf]
U2 [\xc2-\xdf]
U3 [\xe0-\xef]
U4 [\xf0-\xf4]
CHINESE_LABEL ({U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U})+
CHINESE {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U}
CN_EN {CHINESE}|[a-zA-Z]
CN_EN_NUM {CHINESE}|[_a-zA-Z0-9]
UTF8_LABEL {CN_EN}{CN_EN_NUM}+

%%

Expand Down Expand Up @@ -471,7 +474,7 @@ CHINESE_LABEL ({U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U})+
// Must match /* */
throw GraphParser::syntax_error(*yylloc, "unterminated comment");
}
\`{CHINESE_LABEL}\` {
yixinglu marked this conversation as resolved.
Show resolved Hide resolved
\`{UTF8_LABEL}\` {
yylval->strval = new std::string(yytext + 1, yyleng - 2);
if (yylval->strval->size() > MAX_STRING) {
auto error = "Out of range of the LABEL length, "
Expand All @@ -480,7 +483,7 @@ CHINESE_LABEL ({U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U})+
delete yylval->strval;
throw GraphParser::syntax_error(*yylloc, error);
}
return TokenType::CHINESE_LABEL;
return TokenType::UTF8_LABEL;
}
. {
/**
Expand Down
13 changes: 13 additions & 0 deletions tests/tck/features/schema/Schema.feature
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,19 @@ Feature: Insert string vid of vertex and edge
Then the result should be, in any order:
| Field | Type | Null | Default | Comment |
| "时间" | "timestamp" | "YES" | EMPTY | EMPTY |
When executing query:
"""
CREATE TAG `队伍s2`(`名s字ss1` string);
"""
Then the execution should be successful
# desc cn-en mixed tag
When executing query:
"""
DESCRIBE TAG `队伍s2`
"""
Then the result should be, in any order:
| Field | Type | Null | Default | Comment |
| "名s字ss1" | "string" | "YES" | EMPTY | EMPTY |
When executing query:
"""
DROP SPACE issue2009;
Expand Down