Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplest CTE indentation error #276

Open
benji-york opened this issue Jan 28, 2022 · 0 comments
Open

Simplest CTE indentation error #276

benji-york opened this issue Jan 28, 2022 · 0 comments

Comments

@benji-york
Copy link

I noticed several issues around CTEs and indentation. I.e.,

I don't want to pile on, but thought that an issue to track the simplest-possible version of the problem might help.

When I format this query (using the online formatter with default settings):

WITH foo AS (
    SELECT 1 WHERE (1 = 1)
    UNION ALL
    SELECT 1
)
SELECT 1;

I get:

WITH foo AS (
    SELECT
        1
    WHERE (1 = 1)
UNION ALL
SELECT
    1
)
SELECT
    1;

Which demonstrates the indentation issue starting with "UNION ALL".

If the parenthesis in the WHERE clause are removed, the indentation issue does not present. (Note how the clause is moved down and indented while it was on the same line as the WHERE in the previous output.)

WITH foo AS (
    SELECT
        1
    WHERE
        1 = 1
    UNION ALL
    SELECT
        1
)
SELECT
    1;

Looking back at the other issues, the presence of parenthesis may be significant in those as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant