SQL Code Style - Whitespace after curly brackets Follow
Hi,
we are using the default PostgreSQL dialect and the default Code Style for it.
When formatting the following SQL everything is okay:
SELECT colA FROM tab_a
However, when formatting the following SQL we get an unwanted whitespace introduced. We use the curly brackets to insert and replace strings, but woudl like to use the Code Style formatter by DataGrip.
SELECT colA FROM {tab}_a
SELECT colA FROM {tab} _a -- becomes this after formatting.
Is there an option we can change here?
Thanks so much everyone in advance
Please sign in to leave a comment.
If assumed that `{tab}_a` is a full table name with an underscore in it, then this formatting behavior is unusual.
I tried to reformat this piece of code in Build #DB-223.8617.3, but haven't been bale to reproduce it. Therefore, can you please update to 223.8617.3 version and observe this behavior again.
If the issue remains, please let us and we'll have a look.
HI Aleksandr,
we are using Build #PY-223.8617.48, PyCharm 2022.3.2 (Professional Edition), which comes with DataGrip as a bundled plugin.
I can see the change being applied in the Settings preview for Editor > Code Style > SQL > General, as well as when formatting a .sql file.
Thanks
Toby
Hi Toby Ruby,
I was finally able to reproduce this scenario. The problem is that the {} brackets are not conventional to postgres SQL syntax and, thus, are not handled as you would expect them to. We've made a workaround for your specific case. Here's what needs to be done:
1. in File | Settings | Database | Query Execution | User Parameters, add either \{\w\w*} or \{\w+} - both will do
2. Select SQL checkbox only in Languages, hit Apply

Reformatting should eliminate white space and keep the object name consistent.
Hi Aleksandr,
This solution hasn't worked for us.
A screenshot of the applied settings on our end provided below for your reference. Could you please review?
Hi Suraj Gulabani,
Please try to use \{\w\w*} instead. Should be working fine.