Content-Length: 332469 | pFad | http://github.com/JavaScriptor/js-sql-parser/commit/bb66951f1e6c01d4eae2611fdb36db71df0bd64e

BD Merge pull request #33 from TrackTik/master · JavaScriptor/js-sql-parser@bb66951 · GitHub
Skip to content

Commit bb66951

Browse files
authored
Merge pull request #33 from TrackTik/master
feat: add support for "`" quoted alias
2 parents 0374378 + d3c4871 commit bb66951

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)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/JavaScriptor/js-sql-parser/commit/bb66951f1e6c01d4eae2611fdb36db71df0bd64e

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy