Re:Best practices for writing SQL queries
by dragonwriter on Saturday April 10, 2021 @02:05PM
(#26763566)
It makes diffs harder because maintaining the indentation rule (sometimes, depending on what is on other lines) requires changing every line of the query if you go from “INNER JOIN” (equally, outer/right/cross join) to “LEFT JOIN” (equally, full join).
[ Parent
| on HN ]
Re:Best practices for writing SQL queries
by fiddlerwoaroof on Saturday April 10, 2021 @02:21PM
(#26763686)
Nearly every diff tool has -w for this, though: main main annoyance with GitHub is that I can’t enable this as the default diff mode.
Re:Best practices for writing SQL queries
by sodapopcan on Saturday April 10, 2021 @03:02PM
(#26764073)
Yep—`-w` is the default when I blame in my editor but ya, github is really the problem.
Re:Best practices for writing SQL queries
by majewsky on Saturday April 10, 2021 @05:56PM
(#26765511)
At least GitHub now has a UI for enabling it. I remember the dark ages when you had to put ?w=1 on the URL like some sort of animal.
Re:Best practices for writing SQL queries
by hn_throwaway_99 on Saturday April 10, 2021 @02:55PM
(#26764010)
The indentation rules never change. Fortunately, "SELECT" at six letters is as long as the longest first word that starts a clause, which is why when doing, for example, a "LEFT JOIN" you line up the "LEFT" and not the "JOIN, e.g.
SELECT a.foo
FROM alpha a
JOIN beta b ...
would become SELECT a.foo
FROM alpha a
LEFT JOIN beta b ...
Any diff tool correctly highlights the only change is the LEFT.
Re:Best practices for writing SQL queries
by sodapopcan on Saturday April 10, 2021 @03:01PM
(#26764063)
Ya, was thinking after I submitted that SELECT and DELETE are always going to be the longest anyway, so it always works for SQL!