sql-formatter-org / sql-formatter-org/sql-formatter

Feature Request: Format "ON" to separate line

Open
#247 15 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
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

Open the contributing guide

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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.