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

postgresql: better handle DISTINCT clause

Open
#144 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug postgresql
Dominant language
TypeScript
Stars
2.9k
Forks
456
Avg merge
3d 4h
Merged PRs (30d)
3

Description

At present sql-formatter produces:

SELECT
  DISTINCT ON (c1, c2) c1,
  c2
FROM
  t1;

But we expect:

SELECT
DISTINCT ON (c1, c2)
  c1,
  c2
FROM
  t1;

-- or 

SELECT DISTINCT ON (c1, c2)
  c1,
  c2
FROM
  t1;

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 reproducing the PostgreSQL query in sql-formatter and trace how its DISTINCT clause is formatted. Compare the result with the requested examples, then verify that DISTINCT ON appears at the expected indentation without changing the surrounding SELECT list formatting.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, typescript
Domain
databases, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.