-
Notifications
You must be signed in to change notification settings - Fork 111
Open
Description
I noticed several issues around CTEs and indentation. I.e.,
- Bad indentation for CTE and
Count(*) ASin return query statement #258 - Combining CREATE TABLE with CTE affects later formatting #213
- bad indention after CTE #202
- Indentation breaks when
HAVINGclause with subquery is used #195
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.
jacek0x and zignis
Metadata
Metadata
Assignees
Labels
No labels