sql-formatter-org / sql-formatter-org/sql-formatter
Feature Request: Format "ON" to separate line
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
Is there a region so not add OR to the logicalOperatorNewline? Or maybe is there a different way to control that?
Why do you want this feature?
Normally in sql the ON is not on the same line as the join itself. For example:
SELECT
*
FROM
foo
JOIN foo
ON foo.account_id = bar.account_id
AND foo.something = bar.something
AND a = b
This looks a bit weird:
SELECT
*
FROM
foo
JOIN foo ON foo.account_id = bar.account_id
AND foo.something = bar.something
AND a = b
And it is nice to look at the ON and AND clause without having to move your eye to the right. Helps readability.
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
Start by locating the formatter logic for JOIN, ON, AND, and the logicalOperatorNewline option. Reproduce the examples in the issue and trace how the ON clause is positioned relative to JOIN. Done means the formatter can place ON on its own line while preserving the requested AND formatting, with coverage for the shown SQL shape.
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
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100