Comma at the begin for DDLs

Answered

Normally I like my commas at the end of the line, but for DDLs I need the at the beginning of the line (for our automatic code processor tool). 

Is there any way to achieve this with the latest Datagrip?

6 comments
Comment actions Permalink

Francescomucio,

Could you specify the way you generate your DDL?

 

0
Comment actions Permalink

The DDL is just written in Datagrip (where I also format it), but I want to feed it to another tool that will process it.

Because of the way the tool works I need to have the commas at the end of the row. But maybe I am overcomplicating things, the other tool is also created by me, so I could make it work with the current syntax, but commas at the beginning of the line for DDLs would be nice anyway :)

0
Comment actions Permalink

Francescomucio,

You can configure SQL formatter the way you need and check reformat generated code

 

0
Comment actions Permalink

Francescomucio vasily chernov i too have this question. thanks for the suggestion vasily but in this case the DDL to create the table was not generated by datagrip but instead written by hand or pasted in from elsewhere, so for existing code, how can we format it to move the comma from the end to the front and align the data types?  a macro would be fine. i tried to create one but it didn't do what i expected.  Here's a sample of existing code.  Can you tell us how to either include in formatting setup and/or write a macro for existing code?

 

CREATE TABLE IF NOT EXISTS drp.order_channel_source

(
order_channel_id VARCHAR(32),
order_id VARCHAR(32),
store_order_id VARCHAR(32),
order_code VARCHAR(128),
order_date TIMESTAMP WITHOUT TIME ZONE,
discount_code VARCHAR(128),
channel_source VARCHAR(64)

PRIMARY KEY(order_channel_id)
)
DISTKEY (order_id)
SORTKEY (order_id, store_order_id)
;
0
Comment actions Permalink

Same problem here.

I want to change this format:

 

CREATE TABLE Foo (

  a INT,

  b INT

)

 

To this:

CREATE TABLE Foo (

  a INT

 , b INT

)

 

Strangely, there seems to be no way to do that in DataGrip (I am on version 2020.1). For all the other statement types, it is possible to put the comma at the beginning of the line. But no such thing for DDL

0
Comment actions Permalink

Thomas Kejser, Charmaine, Francescomucio,
I created an issue https://youtrack.jetbrains.com/issue/DBE-10575 based on your description. You can track progress and vote for the issue.

0

Please sign in to leave a comment.