darold / darold/pgFormatter

bad formatig on create table with clause

Open
#347 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PLpgSQL
Stars
2k
Forks
121
Avg merge
4d 21h
Merged PRs (30d)
7

Description

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
);

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the discrepancy using the supplied CREATE TEMPORARY TABLE SQL in pgFormatter's console program or online demo. Compare the st_union closing parenthesis and indentation with the expected layout. Done means the formatter emits the corrected layout without disrupting the surrounding CTE formatting.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, sql
Domain
cli, databases, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.