Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: AST to string causes double aliases #1459

Merged
merged 3 commits into from
Sep 24, 2022

Conversation

Buroni
Copy link
Contributor

@Buroni Buroni commented May 4, 2022

Fixes #1426

During ast.toString(), the function alias is being set in two places: At the yy.FuncValue level and the yy.Select level. This is causing double aliases to be generated for functions when stringifying the AST, e.g. SELECT LENGTH(col) AS length AS length.

This problem would have existed on other tokens such as yy.Literals too, but they seem to use an outdated(?) this.alias which always returns undefined. Updating the yy.Literal code to use this.as causes the problem to appear for literals too, e.g. SELECT col AS c AS c.

My solution is to just remove any alias handling-code from tokens which could represent columns, and let yy.Select handle those aliases as it currently does.

@mathiasrw
Copy link
Member

Thank you!

@mathiasrw mathiasrw merged commit 14a4cb7 into AlaSQL:develop Sep 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AST to string causes double aliases
2 participants