SQL - disable auto-format on FROM sub-clause

Answered

Let's say I have such code

 

SELECT * FROM (

SELECT * FROM xxxxxxx

the moment I type closing bracket it formats the code not to my liking.. I can't find the setting to disable this behaviour

9 comments
Comment actions Permalink

@Dawid Nawrot,

Could you provide a screenshot of your current result and a desired one?  Also, it would be handy to get a sample DDL.


What dialect do you use?

0
Comment actions Permalink

This is when I start typing, in order to wrap a query in a outer query

When I type the second parenthesis it will format it to:

But I would like the following:

0
Comment actions Permalink

You need to pay attention to `Subquery` and `Where` formatting options. As for `*`, it's impossible to put it on a separate line for now.

Example settings for PostgreSQL dialect:

0
Comment actions Permalink

Can I disable it completely? I am failing at configuring it to behave like I want. It changes indentation etc. I think it will be easier to completely switch off formatting when I press ")", can I do that?

0
Comment actions Permalink

@Dawid Nawrot,

>I am failing at configuring it to behave like I want

Could you specify SQL Dialect you work with and describe your desired behavior?


> easier to completely switch off formatting when I press ")"

You need to set values to Do not change

0
Comment actions Permalink

Hmm it still didn't work. I set Do not change on PostgreSQL and Generic SQL (just in case).

When I start typing this

SELECT
*
FROM ()

And then if I press enter while being inside the parenthesis I get this, with the cursor being at 5 char (not 4, why?)

SELECT
*
FROM (

)

Whereas I would prefer: 

SELECT
*
FROM (

)

With the cursor being at 4 character, so the regular tab size

0
Comment actions Permalink

@Dawid Nawrot,

Could you specify console dialect you work with?

 

SQL Code formatter depends from dialect you work with. Did you try Reformate code action?

0
Comment actions Permalink

It shows Amazon Redshift but there is no specific code style settings for Redshift, is there?

0
Comment actions Permalink

>It shows Amazon Redshift but there is no specific code style settings for Redshift, is there?

You should use PostgreSQL code style for Redshift.

0

Please sign in to leave a comment.