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

feat(sql/ast): Render AST to SQL #2815

Merged
merged 12 commits into from
Oct 12, 2023
Merged

feat(sql/ast): Render AST to SQL #2815

merged 12 commits into from
Oct 12, 2023

Conversation

kyleconroy
Copy link
Collaborator

@kyleconroy kyleconroy commented Oct 6, 2023

Add a new Format method to AST nodes to support writing an AST tree back to SQL. The rendered SQL is checked to be equivalent to the input SQL, not exact. The tests current run against all query.sql files in pgx/v5 directories. As support is improved, we'll expand to all PostgreSQL queries.

The hope is to eventually use this to power a sqlc fmt subcommand, but that is a ways off from happening.

@kyleconroy kyleconroy marked this pull request as ready for review October 12, 2023 00:49
@kyleconroy kyleconroy changed the title feat(sql/ast): Early support for rendering SQL AST feat(sql/ast): Render AST to SQL Oct 12, 2023
@kyleconroy kyleconroy merged commit 53d1792 into main Oct 12, 2023
8 checks passed
@kyleconroy kyleconroy deleted the kyle/print-ast branch October 12, 2023 18:57
This pull request was closed.
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.

1 participant