sql-formatter
                                
                                 sql-formatter copied to clipboard
                                
                                    sql-formatter copied to clipboard
                            
                            
                            
                        postgresql: better handle DISTINCT clause
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;
The latest version in master produces:
SELECT
  DISTINCT
  ON (c1, c2) c1,
  c2
FROM
  t1;
This isn't really better either :(
With 9.0.0 there's another slight change. It now gets formatted as:
SELECT DISTINCT
  ON (c1, c2) c1,
  c2
FROM
  t1;
Still not there though :(
const reservedSelect = expandPhrases(['SELECT [ALL | DISTINCT] [ON]']); 
should be able to solve the issue?
This would result in:
SELECT DISTINCT ON
  (c1, c2) c1,
  c2
FROM
  t1;
which isn't better. What one really wants is:
SELECT DISTINCT ON (c1, c2)
  c1,
  c2
FROM
  t1;