andialbrecht/sqlparse

Spurious empty line reformatting a query using a subselect

lelit opened this issue · 0 comments

lelit commented

This query:

select c.id, c.value, (select count(*) as cnt from d where d.item_id = id) as "Count", c.whatever
from something as c

is prettified like:

SELECT c.id,
       c.value,

  (SELECT count(*) AS cnt
   FROM d
   WHERE d.item_id = id) AS "Count",
       c.whatever
FROM something AS c

Without the AS "Count" there is no empty line.

Also, wouldn't it be nicer to align the open paren of the subselect to the other columns, or alternatively something like

SELECT 
  c.id,
  c.value,
  (SELECT count(*) AS cnt
   FROM d
   WHERE d.item_id = id) AS "Count",
  c.whatever
FROM something AS c

Thank you!