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

Add SQL formatter #5951

Closed
4 tasks done
ysmilda opened this issue Nov 23, 2022 · 1 comment · Fixed by #6070
Closed
4 tasks done

Add SQL formatter #5951

ysmilda opened this issue Nov 23, 2022 · 1 comment · Fixed by #6070
Assignees
Labels
technical debt Not necessarily broken, but could be done better/cleaner tooling Development tooling
Milestone

Comments

@ysmilda
Copy link
Contributor

ysmilda commented Nov 23, 2022

Summary

Add a formatter for SQL files so they follow a opinionated standard.

Current Situation

No response

Why do we need this? Who uses it, and when?

We have formatters defined for most off our codebase, except for the SQL files. Adding this will make our queries more consistent.

Proposed Implementation

The formatter that we choose has to work with postgres/timescaledb and ignore the ?0 syntax that we use for our bun replacements.

These requirements led to one option so far: sqlfmt. It is very opinionated, the only parameter is line length. But it quite resembles our current "style".

Others I've tried (SQLFluff and sql-formatter) fail on the special syntax.

Contributing

  • I can help by doing more research.
  • I can help by implementing the feature after the proposal above is approved.
  • I can help by testing the feature before it's released.

Code of Conduct

@ysmilda ysmilda added tooling Development tooling needs/triage We still need to triage this labels Nov 23, 2022
@ysmilda ysmilda self-assigned this Nov 23, 2022
@NicolasMrad NicolasMrad added technical debt Not necessarily broken, but could be done better/cleaner and removed needs/triage We still need to triage this labels Nov 29, 2022
@NicolasMrad NicolasMrad added this to the 2022 Q4 milestone Nov 29, 2022
@NicolasMrad NicolasMrad modified the milestones: 2022 Q4, 2023 Q1 Jan 2, 2023
@ysmilda
Copy link
Contributor Author

ysmilda commented Jan 17, 2023

This is blocked on tconbeer/sqlfmt#355.

sqlfmt now supports our naming structure and the bun placeholders. I think it to be a good fit for the stack, however not all postgress keywords are supported yet. This means that the formatting may change when the development moves along.

My proposal is to add the formatter as is and keep track of tconbeer/sqlfmt#262 to update it accordingly. This can be done by switching out the docker container in mage.

@ysmilda ysmilda linked a pull request Feb 23, 2023 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
technical debt Not necessarily broken, but could be done better/cleaner tooling Development tooling
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants