News for hackers. Stuff that matters.
Re:What I Wish Someone Told Me About Postgres by akira2501 on Tuesday November 12, 2024 @05:51PM (#42120703)
> I find that I like English "sentence case" for it,

I could go either way, but if you want to go back and modify a query, this makes it more difficult for me. I just use a block syntax for my queries:

    SELECT   *
    FROM     the_table
    WHERE    some_column = 12
    AND      other_column IS NOT NULL
    ORDER BY order_column;
Re:What I Wish Someone Told Me About Postgres by cwbriscoe on Tuesday November 12, 2024 @06:35PM (#42121202)

   SELECT *
     FROM the_table
    WHERE some_column = 12
      AND other_column IS NOT NULL
 ORDER BY order_column;
I usually don't bother with ALL-CAP keywords.
Re:What I Wish Someone Told Me About Postgres by wruza on Tuesday November 12, 2024 @10:36PM (#42122651)
I use a similar structure but without column alignment.

  SELECT
    a,
    b
  FROM t1
  JOIN t2 ON …
  WHERE cond1
    AND cond2
  ORDER/GROUP/HAVING etc
Re:What I Wish Someone Told Me About Postgres by justanorherhack on Thursday November 14, 2024 @05:38AM (#42134884)
This is the way, everyone else is wrong.
Re:What I Wish Someone Told Me About Postgres by WorldMaker on Tuesday November 12, 2024 @11:03PM (#42122796)
It's a bit of a "Why not both?" situation, I think? You can have blocks and sentence case:

    Select   *
    from     the_table
    where    some_column = 12
    and      other_column is not null
    order by order_column;
That seems so much more readable to me. As I said, that single capital `S` in the outermost "select" has come in surprisingly handy in my experience when scanning through a collection of statements or a transaction or a stored procedure or even just a statement with a bunch of nested sub-selects. It's an interesting advantage I find over "all lower case" or "all upper case" keywords.
Re:What I Wish Someone Told Me About Postgres by 4ggr0 on Wednesday November 13, 2024 @05:10AM (#42124686)
your example is less readable for me. not by a lot, but still.

the other example has the commands, in caps, on the left and the values on the right, in lowercase. your example removes one of those aspects and makes everything lowercase. my brain can ignore all-caps stuff, as these are just commands and the things i actually care about mostly are the values.

but i mean, in the end, it's just preferences. if you write SQL-queries, #1 is that you understand them well :)

Re:What I Wish Someone Told Me About Postgres by Ntrails on Wednesday November 13, 2024 @07:48AM (#42125607)
> your example is less readable for me. not by a lot, but still

Agree, but I wonder how much of that is just the lack of colouring. My brain is suuuuper hard wired to expect all the special keywords to be identified that way as well as by case.

Mostly I'm a caps guy because my ahk scripts expand text like "ssf","w" and "gb"* to be the way I learned to write them at first.