Annoying parentheses while generating DDL

Answered

I am using Datagrip for more than an Year to interact with my Postgres database and it is one of the best SQL IDE's I have used so far.

But I frequently get annoyed by the auto code modification feature while generating DDL for VIEWS, Functions and Stored Procedures from Datagrip.

For example, I create a VIEW using the below code and when I try to VIEW its DDL it gets converted into a format with unwanted paranthesis. It gets even more annoying if there are multiple TABLES, JOINS, CONDITIONS in the query.

Is there any way for DataGrip to not automatically add those paranthesis while generating the DDL?

 

Original SQL VIEW:


CREATE VIEW test_view AS
SELECT table_a.col3, table_a.col4
FROM table_a INNER JOIN table_b ON table_a = table_b ON table_a.col1 = table_b.col1
WHERE table_a.col2 = 'xxx' AND table_b.col2 = 'xxx';

 

Auto-Converted by DataGrip (with annoying paranthesis):

 

CREATE VIEW test_view AS
SELECT table_a.col3, table_a.col4
FROM (table_a INNER JOIN table_b ON table_a = table_b ON ((table_a.col1 = table_b.col1))
WHERE (table_a.col2 = 'xxx' AND table_b.col2 = 'xxx'));
7 comments
Comment actions Permalink

Well you may want to try File -> Settings... -> Editor -> Code Style -> SQL and tic the "Disable formatting" option on one of more of the six tabs.

1
Comment actions Permalink

In 2017.3 you can also try Alt+I on the view in Database tree

0
Comment actions Permalink

Does somebody figured out how to get rid of that REALLY annoying parentheses? My view DDL looks like this

 

Awful. It's not only unreadable, i can't even edit my view until i manually remove all the extra parentheses.

 

Auto-formatting (CMD+OPTION+L) doesn't help in this case.

0
Comment actions Permalink

This is the code given by database, so there is no way for now :(

0
Comment actions Permalink

If that's database issue so why Postico returns pretty result for the same view DDL?

0
Comment actions Permalink

Maxim Sobolevskiy just told me that they have found a way through which this (pretty-print) can be triggered, so it's expected that this option will be available from next release. Current release is: Version: 2019.2.6; Build: 192.7142.42; Released: October 31, 2019.

He did refer me to the documentation from Postgres however, where it says the following:

The pretty-printed format is more readable, but the default format is more likely to be interpreted the same way by future versions of PostgreSQL; avoid using pretty-printed output for dump purposes.

https://www.postgresql.org/docs/9.5/functions-info.html

So it's a decision that one has to make for himself whether to use pretty-print.

Thanks for creating the issue Naresh Kumar Malepati.

 

0

Please sign in to leave a comment.