-
Notifications
You must be signed in to change notification settings - Fork 111
Closed
Labels
Description
Salut Gilles,
Thank you for a great tool. I tried to format a MERGE query using pgFormattter today, and noticed that the result could be improved. To see this, consider the last example on the PostgreSQL documentation's MERGE page:
MERGE INTO wines w
USING new_wine_list s
ON s.winename = w.winename
WHEN NOT MATCHED BY TARGET THEN
INSERT VALUES(s.winename, s.stock)
WHEN MATCHED AND w.stock != s.stock THEN
UPDATE SET stock = s.stock
WHEN NOT MATCHED BY SOURCE THEN
DELETE;When fed through pgFormatter, we get this:
MERGE INTO wines w
USING new_wine_list s ON s.winename = w.winename
WHEN NOT MATCHED BY
TARGET THEN
INSERT
VALUES (s.winename, s.stock)
WHEN MATCHED
AND w.stock != s.stock THEN
UPDATE SET
stock = s.stock
WHEN NOT MATCHED BY
SOURCE THEN
DELETE;Now, there are multiple things one could change here, but I think at the very least each WHEN clause should be on a single line and have the same indentation (as in the PostgreSQL docs), and the INSERT, UPDATE and DELETE keywords should have the same indentation (also as in the PostgreSQL docs).
I would be happy to try to contribute a patch for this, but I must admit I have yet to look at the codebase (beyond grepping for MERGE and seeing that there are no tests for it) :-)
Reactions are currently unavailable