Sqlfmt: an opinionated online SQL formatter
51–60 of 94 posts
Re: Sqlfmt: an opinionated online SQL formatter
#52Prettier actually has a beta Postgres plugin, but progress on it seems to have stalled. Hooking it up with sqlfmt would be neat - then prettier could format SQL inside other languages too, like code fences in Markdown or template literals in JS.
Re: Sqlfmt: an opinionated online SQL formatter
#53Looks really cool, but I have one suggestion. Have you considered using leading commas? It makes big SQL statements much easier to edit and it improves diffs. I normally use trailing commas for my code, but most sql dialects don't support it so I fallback to leading ones there.
It does lead to longer queries and poor use of screen real estate, but it is very readable.
Re: Sqlfmt: an opinionated online SQL formatter
#54Tangentially related. I'm of the opinion that SQL shouldn't be uppercased. I don't want to hit shift or caps lock and I find lowercase easier to read. Are there others out there like me? I assume I'm in the minority, but I don't understand why. People stopped uppercasing HTML tags, why can't we do the same with SQL?
Re: Sqlfmt: an opinionated online SQL formatter
#55Tangentially related. I'm of the opinion that SQL shouldn't be uppercased. I don't want to hit shift or caps lock and I find lowercase easier to read. Are there others out there like me? I assume I'm in the minority, but I don't understand why. People stopped uppercasing HTML tags, why can't we do the same with SQL?
Re: Sqlfmt: an opinionated online SQL formatter
#56Looks really cool, but I have one suggestion. Have you considered using leading commas? It makes big SQL statements much easier to edit and it improves diffs. I normally use trailing commas for my code, but most sql dialects don't support it so I fallback to leading ones there.
Re: Sqlfmt: an opinionated online SQL formatter
#57I would challenge the decision to UPPER CASE keywords, it looks oldschool and is unnecessary since syntax highlighting is ubiquitous. And right-justifying is something that only looks clean for the simplest of queries and wreaks havoc with editors that detect mixed tabs/spaces.
Re: Sqlfmt: an opinionated online SQL formatter
#58Tangentially related. I'm of the opinion that SQL shouldn't be uppercased. I don't want to hit shift or caps lock and I find lowercase easier to read. Are there others out there like me? I assume I'm in the minority, but I don't understand why. People stopped uppercasing HTML tags, why can't we do the same with SQL?
To throw out a tossed-off example:
select
P.full_name, A.full_address, AT.type as address_type_name
from
People as P
inner join
Addresses as A on P.address_id=A.id
where
P.deleted is nullRe: Sqlfmt: an opinionated online SQL formatter
#59Earlier quoted context omitted.
Hey, thank you for the formatter! I really like the way it formats statements. Although I have found two issues: 1. It lowercases table and field names, rendering the formatted statement useless for a project with not exclusively lowercased names. Could you please fix this? 2. I'd appreciate accepting common placeholder "?" as a valid part of the SQL statement so that we can format queries with placeholders. Would th…
The formatter adheres to CockroachDB rules which is why it acts like you describe. Case is insensitive in names unless you double quote it. Postgres-style (CockroachDB is one) uses "$1" for placeholders instead of "?". Adding "?" would complicate our grammar enough that it's not worth adding it. sqlfmt is not super useful for non-postgres grammars.
Re: Sqlfmt: an opinionated online SQL formatter
#60Tangentially related. I'm of the opinion that SQL shouldn't be uppercased. I don't want to hit shift or caps lock and I find lowercase easier to read. Are there others out there like me? I assume I'm in the minority, but I don't understand why. People stopped uppercasing HTML tags, why can't we do the same with SQL?