Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poor formatting for SQL functions #195

Open
klahnakoski opened this issue Mar 3, 2018 · 0 comments
Open

Poor formatting for SQL functions #195

klahnakoski opened this issue Mar 3, 2018 · 0 comments

Comments

@klahnakoski
Copy link

This following formatted case statement is difficult to read. May I suggest that function parameters have their own lines when the parameter list gets "too long", and all the CASE clauses align vertically.

Instead of outputting

(
        CASE 
            WHEN (("v.$string") IS NULL)
                OR (("v.$string") = '')
                THEN NULL
            ELSE SUBSTR("v.$string", CASE 
                        WHEN ((1) IS NULL)
                            OR ((max(0, min(LENGTH("v.$string"), (LENGTH("v.$string")) - (4)))) IS NULL)
                            THEN NULL
                        ELSE (1) + (max(0, min(LENGTH("v.$string"), (LENGTH("v.$string")) - (4))))
                        END, (LENGTH("v.$string")) - (max(0, min(LENGTH("v.$string"), (LENGTH("v.$string")) - (4)))))
            END
        ) = ('test')

ensure multi-line CASE statements have the clauses aligned,

(
    CASE 
    WHEN (("v.$string") IS NULL) OR (("v.$string") = '')
    THEN NULL
    ELSE 
        SUBSTR(
            "v.$string"
            ,CASE 
            WHEN ((1) IS NULL) OR ((max(0, min(LENGTH("v.$string"), (LENGTH("v.$string")) - (4)))) IS NULL)
            THEN NULL
            ELSE (1) + (max(0, min(LENGTH("v.$string"), (LENGTH("v.$string")) - (4))))
            END
            ,(LENGTH("v.$string")) - (max(0, min(LENGTH("v.$string"), (LENGTH("v.$string")) - (4))))
        )
    END
) = ('test') 

thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant