Skip to content

Commit d3c4871

Browse files
feat: add support for quoted alias
1 parent 0374378 commit d3c4871

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/sqlParser.jison

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +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'
130131

131132
<<EOF>> return 'EOF'
132133
. return 'INVALID'
@@ -279,6 +280,8 @@ selectExprAliasOpt
279280
: { $$ = {alias: null, hasAs: null} }
280281
| AS IDENTIFIER { $$ = {alias: $2, hasAs: true} }
281282
| IDENTIFIER { $$ = {alias: $1, hasAs: false} }
283+
| AS QUOTED_IDENTIFIER { $$ = {alias: $2, hasAs: true} }
284+
| QUOTED_IDENTIFIER { $$ = {alias: $1, hasAs: false} }
282285
;
283286

284287
string

test/main.test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,4 +387,14 @@ describe('select grammar support', function() {
387387
'select a from dual order by a desc limit 1, 1 union distinct select a from foo order by a limit 1'
388388
);
389389
});
390+
391+
it('support quoted alias', function() {
392+
testParser('select a as `A-A` from b limit 2;');
393+
testParser('select a as `A#A` from b limit 2;');
394+
testParser('select a as `A?A` from b limit 2;');
395+
testParser('select a as `A/B` from b limit 2;');
396+
testParser('select a as `A.A` from b limit 2;');
397+
testParser('select a as `A|A` from b limit 2;');
398+
testParser('select a as `A A` from b limit 2;');
399+
});
390400
});

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy