Beatifier - how to format multiple join conditions - MERGE statements

YellowShark

Member²
For multiple JOIN conditions I have basically two options:
1. Put them in parenthesis => will end up as single line

SELECT *
FROM destination_table t
USING source_table s ON (t.id1 = s.id1 AND t.id2 = s.id2)
WHERE (t.key = 123 AND t.key2 = 456);

2. Don't put them in parenthesis => will end up as individual lines underneath each other:

SELECT *
FROM destination_table t
USING source_table s ON t.id1 = s.id1
AND t.id2 = s.id2
WHERE t.key = 123
AND t.key2 = 456;

Same behavior seen is also shown in where-clauses.

So basically in this scenarios I have a choice, depending on personal preference and read-ability.

Unfortunately for the MERGE-statement there is NO choice.
Since you have to put the JOIN conditions in the ON ( ... ) clause, and thus, in parenthesis,
you will always end up with one (sometimes very long!) line

MERGE INTO destination_table t
USING source_table s
ON (t.id1 = s.id1 AND t.id2 = s.id2 AND t.key = 123)
WHEN MATCHED THEN
UPDATE
SET t.value = s.value;

I would like to have more control over this behavior, especially for MERGE-statements (similar to the Items-treatment of DML statements).
Thanks
 
Back
Top