CTE formatting in DataGrip 2018.2

Answered

Previously, CTEs in my code were always wrapped and indented like this:

WITH test AS (
SELECT *
FROM table
WHERE condition
)
SELECT *
FROM test;

Now, in DataGrip 2018.2, I always end up with this:

WITH test AS (SELECT *
FROM table
WHERE condition)
SELECT *
FROM test;

I strongly prefer the first one but after hours of fiddling with the new Code Style settings, I cannot find a way to get the formatting to how it used to be. There are settings for subqueries, but these don't seem to apply to CTEs. Can you please advise/fix this? 

11 comments
Comment actions Permalink

You're welcome to watch/vote for the issue https://youtrack.jetbrains.com/issue/DBE-6798

0
Comment actions Permalink

+1 This is very annoying.. I have also fiddled with the settings for quite some time now.

It seems that CTE's are not recognized as subqueries!

0
Comment actions Permalink

A fix will be available in a EAP build or in DataGrip 2018.3.

0
Comment actions Permalink

The fix doesn't seem to work in 2018.3. I set "Place elements on" to new line. But it doesn't seem to take

0
Comment actions Permalink

How to get the mentioned style in DataGrip 2018.3:

0
Comment actions Permalink

Ok this is great. Some what off topic but I have my SELECT to elements on new line now as well. I'm finding the first element is not lining but the following elements. Looks some what like this:

SELECT
     a.column
            , a.column2
            , a.column3

I'd like:

SELECT
              a.column
            , a.column2
            , a.column3

Any way to make this happen? (loving the new styles features though)

0
Comment actions Permalink

Hmm, such style is not supported yet (we're not testing our formatter with such style — so you cannot assume it will work in future releases even if you manage to setup it in the current one). Please file a feature request :)

0
Comment actions Permalink

For where to submit the feature request

0

Please sign in to leave a comment.