pgFormatter icon indicating copy to clipboard operation
pgFormatter copied to clipboard

Bad indentation with simple join?

Open anttilinno opened this issue 3 years ago • 0 comments

Good day,

I will just post an example and if this looks like it could use improvement, I will file an issue correctly. If this is expected behavior, I saved a bit of time :smile:

This is formatter output

SELECT
  z.zoo_id,
  z.log_date,
  a.firstname,
  a.lastname,
  zb.break_start
FROM
  zoo z
  JOIN animals a ON z.animal_id = a.animal_id
    AND z.zoo_id = 9
  JOIN zoo_breaks zb ON z.zoo_id = zb.zoo_id
    AND Date_trunc('minute', zb.break_start) - Date_trunc('minute', z.opening_time) < '2 hours'::interval
  AND zb.automatic = TRUE
WHERE
  z.log_date >= '2022-01-01'
ORDER BY
  z.worker_id;

I would assume JOIN conditions are aligned and would like to see output:

SELECT
  z.zoo_id,
  z.log_date,
  a.firstname,
  a.lastname,
  zb.break_start
FROM
  zoo z
  JOIN animals a ON z.animal_id = a.animal_id
    AND z.zoo_id = 9
  JOIN zoo_breaks zb ON z.zoo_id = zb.zoo_id
    AND Date_trunc('minute', zb.break_start) - Date_trunc('minute', z.opening_time) < '2 hours'::interval
    AND zb.automatic = TRUE
WHERE
  z.log_date >= '2022-01-01'
ORDER BY
  z.worker_id;

Best regards.

anttilinno avatar Feb 17 '22 06:02 anttilinno