Skip to content

Commit

Permalink
Schema support mixed Chinese and English
Browse files Browse the repository at this point in the history
  • Loading branch information
heroicNeZha committed Dec 9, 2021
1 parent d42203d commit 20229b7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
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; }
| 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}\` {
\`{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 |
| "名sss1" | "string" | "YES" | EMPTY | EMPTY |
When executing query:
"""
DROP SPACE issue2009;
Expand Down

0 comments on commit 20229b7

Please sign in to comment.