Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 42efe32

Browse files
committed
fix: fix support for quoted alias
1 parent 315faf7 commit 42efe32

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

‎src/sqlParser.jison‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ UNION return 'UNION'
127127
[a-zA-Z_\u4e00-\u9fa5][a-zA-Z0-9_\u4e00-\u9fa5]* return 'IDENTIFIER'
128128
\. return 'DOT'
129129
['"][a-zA-Z_\u4e00-\u9fa5][a-zA-Z0-9_\u4e00-\u9fa5]*["'] return 'QUOTED_IDENTIFIER'
130-
[`].+[`] return 'QUOTED_IDENTIFIER'
130+
([`])(?:(?=(\\?))2円.)*?1円 return 'QUOTED_IDENTIFIER'
131131

132132
<<EOF>> return 'EOF'
133133
. return 'INVALID'
@@ -285,8 +285,7 @@ selectExprAliasOpt
285285
;
286286

287287
string
288-
: QUOTED_IDENTIFIER { $$ = { type: 'String', value: 1ドル } }
289-
| STRING { $$ = { type: 'String', value: 1ドル } }
288+
: STRING { $$ = { type: 'String', value: 1ドル } }
290289
;
291290
number
292291
: NUMERIC { $$ = { type: 'Number', value: 1ドル } }
@@ -328,6 +327,14 @@ identifier_list
328327
: identifier { $$ = { type: 'IdentifierList', value: [ 1ドル ] } }
329328
| identifier_list ',' identifier { $$ = 1ドル; 1ドル.value.push(3ドル); }
330329
;
330+
quoted_identifier
331+
: QUOTED_IDENTIFIER { $$ = { type: 'Identifier', value: 1ドル } }
332+
| quoted_identifier DOT QUOTED_IDENTIFIER { $$ = 1ドル; 1ドル.value += '.' + 3ドル }
333+
;
334+
quoted_identifier_list
335+
: quoted_identifier { $$ = { type: 'IdentifierList', value: [ 1ドル ] } }
336+
| quoted_identifier_list ',' quoted_identifier { $$ = 1ドル; 1ドル.value.push(3ドル); }
337+
;
331338
case_expr_opt
332339
: { $$ = null }
333340
| expr { $$ = 1ドル }
@@ -353,6 +360,7 @@ simple_expr_prefix
353360
simple_expr
354361
: literal { $$ = 1ドル }
355362
| identifier { $$ = 1ドル }
363+
| quoted_identifier { $$ = 1ドル }
356364
| function_call { $$ = 1ドル }
357365
| simple_expr_prefix { $$ = 1ドル }
358366
| '(' expr_list ')' { $$ = { type: 'SimpleExprParentheses', value: 2ドル } }

‎test/main.test.js‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,13 @@ describe('select grammar support', function() {
408408
`);
409409
});
410410

411-
it('bugfix table alias2', function() {
411+
it('bugfix table alias2', function() {
412412
testParser('select a.* from a t1 join b t2 on t1.a = t2.a')
413-
})
413+
});
414+
415+
it('support quoted alias: multiple alias and orderby support', function () {
416+
testParser('select a as `A A`, b as `B B` from z');
417+
testParser('select a as `A A` from z order by `A A` desc');
418+
testParser('select a as `A A`, b as `B B` from z group by `A A`, `B B` order by `A A` desc');
419+
});
414420
});

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /