5 ms·
> 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
by SPBS 2y 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';
- emmelaich 2y agoAlso, could uppercase go away and never come back? Please?
- y42 2y agobut why? it's a quick and easy way to distinguish commands from arguments
- dagss 2y agoWhy do you not make that argument for "if" and "else" in Go/Java/...? Editors highlight syntax.
- thiht 2y agoEditors 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 2y agoEditors 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.highlight-string-code https://marketplace.visualstudio.com/items?itemName=iuyoy.hi...
- mijamo 2y agoI 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.
- eddd-ddde 2y agoAny jetbrains IDE with sql tools will work perfectly in my experience.
- emmelaich 2y agoMaybe it's time for programming languages for use something like markdown in strings for embedded sql and dsl. e.g. ```sql ```
- dagss 2y agoI 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..
- vlvdus 2y agoThat would be a nice change too. Also THEN, BEGIN, END to replace varous brackets.
- beachy 2y agoIMO 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 2y agoThis. 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 2y agoAutomatic 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.
- deleted 2y ago[deleted]
- Izkata 2y agoI 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.
- harterrt 2y agoAgreed. Fwiw, Mozilla’s style guide prohibits rivers like this. https://docs.telemetry.mozilla.org/concepts/sql_style https://docs.telemetry.mozilla.org/concepts/sql_style