SqlDbx Forum

SqlDbx

You are not logged in.

#1 2017-03-03 16:13:57

garbuya
Member

Suggestion -- More formatting options for CASE

It looks like CASE needs more formatting options

My Line breaks settings are set to
Before comma
Before AND/OR

I expect, that these rules also apply to CASE, but it is not true:

Example:
CASE
    WHEN A = B
    AND C = D
        THEN 1
    WHEN E = F
    AND G = H
        THEN 2
    ELSE 3
END       

IF "Format CASE Statements on multiple lines" is checked then the result is

CASE
    WHEN A = B AND C = D THEN 1
    WHEN E = F AND G = H THEN 2
    ELSE 3
END


IF "Format CASE Statements on multiple lines" not checked then the result is

CASE WHEN A = B AND C = D THEN 1 WHEN E = F AND G = H THEN 2 ELSE 3 END

In both cases for multiple complicated conditions formatted CASE lines are very long and non readable.

Also, both formatting results contradict with Line Break settings

I think that Formatter should leave the existing line breaks alone and only add the new breaks and indents.

And for CASE statements options should be

Break before WHEN/AND/OR/ELSE/THEN
Break after CASE/WHEN/AND/OR/ELSE/THEN
Indent THEN

Offline

Board footer

Powered by FluxBB