Tangentially 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?
Sqlfmt: an opinionated online SQL formatter
81–90 of 94 posts
Re: Sqlfmt: an opinionated online SQL formatter
#82Tangentially 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
#83Looks 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.
Oh god, no. No leading commas, anywhere. Not in javascript, not in SQL. It's like nails on a chalkboard. Funny because I was reading other people's comments and thinking "wow, that person is VERY opinionated on query formatting" (but now here I am).
There are opinions, and there are crimes against humanity (although that is a matter of opinion).
Re: Sqlfmt: an opinionated online SQL formatter
#84My opinion: text should never be aligned to right as the keywords here are.
The style is similar to https://www.sqlstyle.guide/, which is excellent.
Re: Sqlfmt: an opinionated online SQL formatter
#85Earlier quoted context omitted.
First, I'm sure mere inertia plays a role, but there are practical reasons as well if you're writing more than trivial SQL queries. In most other languages you can read the statements fairly linearly, one statement leads to the next, and to the next, etc. At least within functions/methods and then you usually have indentation to help with understanding boundaries. Each "logical line" may be spread out over one or eve…
Wouldn't syntax highlighting help with most of the issues you've outlined?
I wonder if programming languages should have a way of specifying that a string constant contains embedded code or a template, so text editors can display it accordingly.
I deal with a lot of SQL embedded in code, and prefer uppercase keywords as it seems to help me visually parse the overall file.
Re: Sqlfmt: an opinionated online SQL formatter
#86Earlier quoted context omitted.
Wouldn't syntax highlighting help with most of the issues you've outlined?
Syntax highlighting is a huge boon working with SQL, but unfortunately you often find you are working with SQL embedded as a string in some other programming language. I wonder if programming languages should have a way of specifying that a string constant contains embedded code or a template, so text editors can display it accordingly. I deal with a lot of SQL embedded in code, and prefer uppercase keywords as it se…
Re: Sqlfmt: an opinionated online SQL formatter
#87Tangentially 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?
I never uppercase the SQL keywords. If it's more than a one-liner select statement, I format it so the indentation tells me what's going on. 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 null
Plus, it's more comfortable to type as well.
Re: Sqlfmt: an opinionated online SQL formatter
#88Earlier quoted context omitted.
Wouldn't syntax highlighting help with most of the issues you've outlined?
Syntax highlighting is a huge boon working with SQL, but unfortunately you often find you are working with SQL embedded as a string in some other programming language. I wonder if programming languages should have a way of specifying that a string constant contains embedded code or a template, so text editors can display it accordingly. I deal with a lot of SQL embedded in code, and prefer uppercase keywords as it se…
Re: Sqlfmt: an opinionated online SQL formatter
#89Brief question, only tangentially related: Is it me or is "opinionated" software popping up all over the place? It looks to me like the author considers it a selling point, too. Can someone explain to me why I would want an "opinionated" software over any regular old software? Especially over a configurable software? I'm not a native speaker, but I never encountered "opinionated" being used with positive connotation.…
The word does indeed have initially negative connotations. Perhaps it resonates more positively now to people who have had to work with "flexible" software such as Spring in the old days. There were 100 ways to skin a cat with old Spring, and each way was a tortuous devil's brew of XML. Googling for any solution was a nightmare, exacerbated by hundreds of wannabe experts polluting the interwebs with their own strange…
In programming, there's the idea that "The code shouldn't merely work, it should clearly work". If your configuration system becomes so complex that the same principle applies there, that's a bad sign.
Re: Sqlfmt: an opinionated online SQL formatter
#90Author here. Based on feedback I am going to make a sqlfmt binary for easy editor integration. You can currently already do this by using the CockroachDB binary ( https://www.cockroachlabs.com/docs/releases/v2.1.0-beta.2018... ) but understandably people want a more minimal solution.
Any chance of allowing keywords that are specific to a SQL implementation? (e.g. PostgreSQL)
If I enter "CREATE MATERIALIZED VIEW ... WITH DATA;" in for example, it would tell me "materialized" and "with data" is wrong.