darold / pgFormatter

A PostgreSQL SQL syntax beautifier that can work as a console program or as a CGI. On-line demo site at http://sqlformat.darold.net/
PostgreSQL License
1.69k stars 101 forks source link

bad formatig on create table with clause #347

Open candux opened 1 month ago

candux commented 1 month ago

The output of this SQL is very hard to read. The closing line of st_union should be on the same line and the indentation is all messed up Input:

CREATE TEMPORARY TABLE IF NOT EXISTS square_poly2 AS (
    WITH united AS (
    SELECT
        level,
        st_union (st_buffer (geom, 0.01)) AS geom
    FROM
        osmgrid._a_polygones
    GROUP BY
        level
    ),
    united2 AS (
        SELECT
            level,
            st_union (st_buffer (geom, 0.01)) AS geom
        FROM
            osmgrid._a_polygones
        GROUP BY
            level
    )
            SELECT
                *
            FROM
                united
);

Output:

CREATE TEMPORARY TABLE IF NOT EXISTS square_poly2 AS (
    WITH united AS (
    SELECT
        level,
        st_union (st_buffer (geom, 0.01)
) AS geom
    FROM
        osmgrid._a_polygones
    GROUP BY
        level),
        united2 AS (
        SELECT
            level,
            st_union (st_buffer (geom, 0.01)
) AS geom
        FROM
            osmgrid._a_polygones
        GROUP BY
            level
)
            SELECT
                *
            FROM
                united
);