Skip to content

Make SELECT rules more explicit in the SQL style guide

Eli Kastelein requested to merge explicit-select-in-sql-style-guide into master

Changes:

  • The example query was already using 2 spaces for indents, but the guide says to use 4. I think 2 is more natural and seems more common in our code base.
  • I propose we either put all the columns on the same line or give every column it's own line. The key difference here is that if you're going multi-line, don't put anything else on the same row as SELECT. I'm essentially proposing this: https://github.com/mattm/sql-style-guide#single-line-vs-multiple-line-queries except without a hard rule on when to use single line vs multiple.
SELECT a, b
FROM data

or

SELECT
  a,
  b
FROM data

but not

SELECT a,
      b
FROM data
Edited by Eli Kastelein

Merge request reports