PgFormatter: A PostgreSQL SQL syntax beautifier
github.com
github.com
[1] http://sqlformat.darold.net/
Also, a similar tool was recently discussed: https://news.ycombinator.com/item?id=18087514
select*from"MyTable"where"column"=3(Implementing a SQL formatter in pure SQL is not impossible, but would be quite a tour de force. Just a thought.)
I remember trying the one from TFA and NOPE-ing out immediately. Similarly, "sqlfmt" that was on HN recently. If there was an official Postgres formatter, I would probably persevere despite whatever oddities it would inevitably have.
Not knocking either project - just pondering adoption.
SELECT field, other_field
FROM table
WHERE some_thing IN (
SELECT id
FROM other_table
)
AND other_field IS NOT NULL
(mostly it's right-aligning keywords, but there are a few other weird tweaks)* ORDER BY
* INNER JOIN
etc
SELECT
field,
other_field
FROM
TABLE
WHERE
some_thing IN (
SELECT
id
FROM
other_table)
AND other_field IS NOT NULL
I'd have expected the last line to have one less indentation level...Maybe you do, but that doesn't seem very OSS.