Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

God, everyone's going to hate me for this. (I will have earned it, I think.)

    SELECT ...
     WHERE foo = 1
       AND bar = 2
Each keyword gets a new line, the middle gutter between keyword and expressions stays in the same place, and things get really, really fugly if I need a subselect or whatever. Any given line can be commented out. (And no, none of that leading comma bullshit, somehow that looks nasty to me.) Downvote this into oblivion to protect the junior developers from being infected by whatever degeneracy has ahold of me.


You may have missed what I was getting at.

In order to quickly comment out the "foo = 1" here, you cannot simply comment out the whole line because it would become syntactically invalid:

     SELECT ...
     --WHERE foo = 1
       AND bar = 2
I have a single keyboard shortcut to comment/uncomment a line because I like to work briskly with as little unnecessary typing.

It has nothing to do with indentation or being "fugly". I'm talking about interactive exploration of prototyping when the final SQL isn't set in stone.


I slowly come to creating vim scripts for all that. I already use `alt-,` for triggering the final comma on a line. Maybe with modern LLMs I just need to prompt a vimscript that detects where the line is (SQL condition, array item, json, etc) and use `alt-,` to do the right thing. Or something like "fixing" the whole block with `g,ap`. Because all this is irritating and no one does anything with it for decades.


Since we're already here, we could think about trailing AND, actually. Look:

  SELECT a, sum(b),
   WHERE foo = 1
     AND GROUP BY a
Sounds pretty SQL to me.


This is cursed, but also entirely consistent with the trailing comma proposal.

It'd sure look funny if all keywords that connected clauses together were trailable, though.

    SELECT a, sum(b),
    FROM stuff
    WHERE foo = 1
       OR GROUP BY a
Or just as horrifying:

    SELECT a, b, c,
    FROM foo
    UNION ALL
    SELECT a, b, c,
    FROM bar
    UNION ALL


Those aren't horrifying to me, only problem is that I want the keywords to right-align with each other.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: