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? 

4
12 comments

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

0
Avatar
Permanently deleted user

+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

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

0
Avatar
Permanently deleted user

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

How to get the mentioned style in DataGrip 2018.3:

0
Avatar
Permanently deleted user

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

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
Avatar
Permanently deleted user

Got a link :)?

0
Avatar
Permanently deleted user

For where to submit the feature request

0
Can you provide the formatting structure of CTEs you're after and a screenshot of the formatting settings you've configured in DataGrip?
0

Please sign in to leave a comment.