Movatterモバイル変換


[0]ホーム

URL:


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

fix: fix support for quoted alias#37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
albin3 merged 3 commits intoJavaScriptor:masterfromCapo93:master
Feb 4, 2021

Conversation

Capo93
Copy link
Contributor

Hi,
i found some issue with the support of quoted aliases.

CASE 1: multiple quoted alias

select aas`A A`, aaas`A AA`from b

Test result: OK
Select Item expected:

"selectItems": {"type":"SelectExpr","value": [{"type":"Identifier","value":"a","alias":"`A A`","hasAs":true},{"type":"Identifier","value":"b","alias":"`B B`","hasAs":true}]},

Received:

"selectItems": {"type":"SelectExpr","value": [{"type":"Identifier","value":"a","alias":"`A A`, b as `B B`","hasAs":true}]},

The RegEx[`].+[`] match from first backquote to last backquote. The behavior should be from one backquote to the next. Same issue for next case.

CASE 2: quoted alias in orderBy

select aas`A A`from zorder by`A A`desc
     Error: Parse error on line 1:...om z order by `A A` desc-----------------------^Expecting 'EOF', ';', 'UNION', ')', ',', 'FROM', got 'DESC'

The 'a' alias in this case is:A A` from z order by `A A

--

I replace the ReqEx with this:([`])(?:(?=(\\?))\2.)*?\1
And add quoted_identifier as Identifier (not as String) in expr.
The result in orderby:

"orderBy": {"type":"OroupBy","value": [{"type":"GroupByOrderByItem","value": {"type":"Identifier","value":"`A A`"},"sortOpt":"DESC"}],"rollUp":null},

Hope my fix are correct and helpfull!
Thanks a lot for this library:)!

@Capo93
Copy link
ContributorAuthor

Also add support for double quote alias

        throw error;        ^Error: Parse error on line 1:...ect customerName as "Customer Name" from -----------------------^

adding| AS STRING { $$ = {alias: $2, hasAs: true} } inselectExprAliasOpt

@albin3
Copy link
Member

hello@Capo93 , thanks for the pr!

I think it's better to mergeidentifier andquoted_ identifier into one symbol. Can you try this?

@Capo93
Copy link
ContributorAuthor

I tried and it works. In last commit I mergequoted_identifier inidentifier.

@albin3albin3 added the bug labelMay 13, 2020
@albin3albin3 merged commit7f3b853 intoJavaScriptor:masterFeb 4, 2021
@albin3
Copy link
Member

hi@Capo93 , thanks for the pr. it's merged and released at 🎉 v1.4.1 🎉.

Capo93 reacted with rocket emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@albin3albin3albin3 approved these changes

Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@Capo93@albin3

[8]ページ先頭

©2009-2025 Movatter.jp