Skip to content

Better formatting of CASE when using format query #1050

@jonjacs

Description

@jonjacs

Is your feature request related to a problem? Please describe.
It is very annoying that the query formatter does not reformat CASE and WHEN clauses in an easy to read format.

An example after the query formatter has done it's thing:

SELECT
    CASE WHEN variable1 IS NOT NULL
    AND variable1 != '' THEN variable1 WHEN variable2 IS NOT NULL
    AND variable2 != '' THEN variable2 ELSE CASE WHEN variable3 IS NOT NULL
    AND variable3 != '' THEN variable3 ELSE '' END END AS variable
FROM
    variables

Describe the solution you'd like
I would prefer if the formatting could be something like:

SELECT
    CASE
        WHEN variable1 IS NOT NULL
        AND variable1 != '' THEN variable1
        WHEN variable2 IS NOT NULL
        AND variable2 != '' THEN variable2
        ELSE
            CASE
                WHEN variable3 IS NOT NULL
                AND variable3 != '' THEN variable3
                ELSE ''
            END
    END AS variable
FROM
    variables

Describe alternatives you've considered
I format that part manually after the auto format.

Environment (please complete the following information):

  • Device: MacBook Pro
  • OS: macOS 15
  • SQLPro app Version: SQLPro Studio 2025.7 (Build 111117)
  • Installation source: App Store
  • Target database server: PostgreSQL

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions