News for hackers. Stuff that matters.
Re:Sqlfluff the SQL Linter for Humans by extr on Wednesday October 06, 2021 @09:04PM (#28780490)
Nice changes, I like it! I will say I really like aligning the join clauses, but I'll try writing things this way for a little while and see if it sticks.
Re:Sqlfluff the SQL Linter for Humans by janto on Thursday October 07, 2021 @06:35AM (#28784520)
The only thing I require from an SQL formatter is to make typos and boolean mistakes super easy to spot, especially as it grows in size. At first glance it might seem strange, but I like indentation on even the first term of an AND.

    SELECT
        a,
        b,
        count(*) as count
    FROM
        table
    JOIN
        table2
    ON
            table.key1 = table2.key1
        AND
            table.key2 = table2.key2
        AND
            -- 1 day apart
            DATEADD('day', 1, table.key3) = table2.key3
    WHERE
            cond1
        AND
            cond2
        AND
            (
                cond3
            OR
                cond4
            )
    GROUP BY
        (a, b)
    ORDER BY
        count desc,
        a asc
    LIMIT
        1000
    ;
Yes, that's a lot of whitespace, but it helps for complex queries.
Re:Sqlfluff the SQL Linter for Humans by marcosdumay on Thursday October 07, 2021 @10:22AM (#28786628)
Well, there's an inherent conflict between making individual queries easier to read and making your entire code easier to read.

How much whitespace you need is completely dependent on what exactly you are writing.