SPBS
a year 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';
    SELECT
        file_hash
    FROM
        file_system
    WHERE
        file_name = '.vimrc';abraae
a year 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 year 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 year 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 year ago
Also, could uppercase go away and never come back? Please?
y42
a year ago
but why? it's a quick and easy way to distinguish commands from arguments
dagss
a year ago
Why do you not make that argument for "if" and "else" in Go/Java/...?
Editors highlight syntax.
thiht
a year 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 year 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 year 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.
dagss
a year ago
I use Jetbrains and there is at least full coverage for MSSQL in my experience, which is a huge dialect -- not only syntax highlighting but full IDE features like autocompletion and target name refactoring etc.
And 10 other dialects are listed..
emmelaich
a year ago
Maybe it's time for programming languages for use something like markdown in strings for embedded sql and dsl. e.g.
```sql
```
eddd-ddde
a year ago
Any jetbrains IDE with sql tools will work perfectly in my experience.
vlvdus
a year ago
That would be a nice change too. Also THEN, BEGIN, END to replace varous brackets.
harterrt
a year ago
Agreed. Fwiw, Mozilla’s style guide prohibits rivers like this.
Izkata
a year 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 year ago