SPBS
a day ago
> Spaces should be used to line up the code so that the root keywords all end on the same character boundary.
SELECT file_hash
FROM file_system
WHERE file_name = '.vimrc';
This style is annoying and I wish it gained less traction. It looks neat but it puts so much burden on the query writer, especially when you modify the query and all of the sudden you need to indent multiple lines just to make them all align. You know what's neat and still easy to modify/diff? Just indent a new line for each row. SELECT
file_hash
FROM
file_system
WHERE
file_name = '.vimrc';
abraae
a day ago
IMO in the modern day there is no place for any indentation styling that can't be achieved automatically via a pretty printer such as golang has.
snorremd
a day ago
This. Relying on developers manually trying to follow a style guide is a recipe for not having a consistent style. Instead something like pgFormatter should be used. I'm not sure what the state of SQL formatters and IDE support is these days. Not sure how many command based options there are.
And people who use things like Datagrip or other IDEs will probably format with their IDE's preferences unless there is a plugin for things like pgFormatter. This works well if there is a company mandated editor/IDE, but not so well when you have developers across various editors and IDEs.
kmoser
a day ago
Automatic formatters and pretty printers never seem to be able to make the exceptions necessary for me to use them. For example, I want the contents of all my HTML tags to be formatted as one long line (think of <p> tags), except when they happen to contain a SQL statement which I want to remain formatted exactly as written.
emmelaich
a day ago
Also, could uppercase go away and never come back? Please?
y42
a day ago
but why? it's a quick and easy way to distinguish commands from arguments
dagss
a day ago
Why do you not make that argument for "if" and "else" in Go/Java/...?
Editors highlight syntax.
thiht
a day ago
Editors don’t syntax highlight SQL queries written as strings. That’s the main reason I write my queries with uppercase keywords in my Go programs
wcrossbow
a day ago
Editors can highlight SQL queries embedded as strings. Neovim can do it, and I'm pretty confident it's not going to be alone in that respect.
edit: Not the editor I use but thought it might be helpful. Here is an extension, which I haven't tested, to do this in VSCode: https://marketplace.visualstudio.com/items?itemName=iuyoy.hi...
mijamo
a day ago
I have never seen a syntax highlighter for SQL that actually covers the real deal from Postgres dialect. Basic stuff is covered and then suddenly you use a combination that isn't covered and the colors are all wrong. This is even true for pgadmin, which is ironic. Unlike most programming languages, SQL built in syntax is huuuuuge and it is very hard to cover it all, especially as it varies with the dialect.
vlvdus
a day ago
That would be a nice change too. Also THEN, BEGIN, END to replace varous brackets.
harterrt
a day ago
Agreed. Fwiw, Mozilla’s style guide prohibits rivers like this.
Izkata
a day ago
I find splitting out over lines like that harder to read because the table-like columns now overlap with each other and aren't aligned with the keyword they belong to.
user
a day ago