sql-formatter-org / sql-formatter-org/sql-formatter
Feature Request: Insert newline after WITH clause
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 456
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 3
Description
Describe the Feature
Are there ways to separate the line with using other character, not the semicolon?
I think it is much more readable if the CTE and the actual query separate with a blank line. However, if I use the formatter there are no ways add a blank line except for using the semicolon(;). Thus, the result query looks like the one below.
with
cte (id, name) AS (
select
*
from
users
)
select
supplier_name,
city
from
(
select
*
from
suppliers
join addresses on suppliers.address_id = addresses.id
) as suppliers
where
supplier_id > 500
order by
supplier_name asc,
city desc
;
Why do you want this feature?
As you might think it is possible to separate with the semicolon, so why we need the other way. The one below raises the syntax error because SQL needs to execute the select ... part after the with ... because of the semicolon(;), which I use to separate a new line.
with
cte (id, name) AS (
select
*
from
users
)
;
select
supplier_name,
city
from
(
select
*
from
suppliers
join addresses on suppliers.address_id = addresses.id
) as suppliers
where
supplier_id > 500
order by
supplier_name asc,
city desc
;
Hence, for the readability, I think there are some other ways to add a new line for my two cents.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The payload names no files or tests. Start by tracing how WITH clauses, semicolons, and blank lines are formatted, then inspect any existing newline options. Done means the formatter can separate the CTE from the following query with a blank line without treating it as a statement terminator, while preserving the shown SQL structure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- sql, typescript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100