Skip to content

Conversation

@kyleconroy
Copy link
Collaborator

@kyleconroykyleconroy 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.

@kyleconroykyleconroy marked this pull request as ready for review October 12, 2023 00:49
@kyleconroykyleconroy changed the title feat(sql/ast): Early support for rendering SQL ASTfeat(sql/ast): Render AST to SQLOct 12, 2023
@kyleconroykyleconroy merged commit 53d1792 into mainOct 12, 2023
@kyleconroykyleconroy deleted the kyle/print-ast branch October 12, 2023 18:57
alfonsodev pushed a commit to ExponentiaTeam/sqlc that referenced this pull request Oct 13, 2025
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.
Sign up for freeto 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.

2 participants

@kyleconroy