Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions src/sqlParser.jison
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ UNION return 'UNION'
[a-zA-Z_\u4e00-\u9fa5][a-zA-Z0-9_\u4e00-\u9fa5]* return 'IDENTIFIER'
\. return 'DOT'
['"][a-zA-Z_\u4e00-\u9fa5][a-zA-Z0-9_\u4e00-\u9fa5]*["'] return 'QUOTED_IDENTIFIER'
[`].+[`] return 'QUOTED_IDENTIFIER'

<<EOF>> return 'EOF'
. return 'INVALID'
Expand Down Expand Up @@ -279,6 +280,8 @@ selectExprAliasOpt
: { $$ = {alias: null, hasAs: null} }
| AS IDENTIFIER { $$ = {alias: $2, hasAs: true} }
| IDENTIFIER { $$ = {alias: $1, hasAs: false} }
| AS QUOTED_IDENTIFIER { $$ = {alias: $2, hasAs: true} }
| QUOTED_IDENTIFIER { $$ = {alias: $1, hasAs: false} }
;

string
Expand Down
10 changes: 10 additions & 0 deletions test/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,4 +387,14 @@ describe('select grammar support', function() {
'select a from dual order by a desc limit 1, 1 union distinct select a from foo order by a limit 1'
);
});

it('support quoted alias', function() {
testParser('select a as `A-A` from b limit 2;');
testParser('select a as `A#A` from b limit 2;');
testParser('select a as `A?A` from b limit 2;');
testParser('select a as `A/B` from b limit 2;');
testParser('select a as `A.A` from b limit 2;');
testParser('select a as `A|A` from b limit 2;');
testParser('select a as `A A` from b limit 2;');
});
});