Formatting , quoting, aliases

Answered

Hi , i don't understand how this works … it feels like a bug.

On mssql language, I want my table aliases to be in lower case ,  and that my table names do not change, and i want to add bracket (no quotes) to everything

Like this : 
select * from [MyTable] [mt]
join                   [JoinedTable] [jt] on [jt].[foreign_key] = [mt].[primarey_key]

How can i achieve this formatting ?
I'm really struggling ! 

Currently, my aliases are upper case , like [MyTable] [MT]
and when i do a join, Datagrips adds “ to the aliases, that is so weird , like :  join [JoinedTable] ”[JT]" !!! 
Why ??

Please help

0
10 comments

Hello,

Please check code style settings in “Settings | Editor | Code Style | SQL | MS SQL Server, MS Azure - Case”.

0

yep, but nothing works for me. Here is my setup.

the result is : 

aliases are upper case, and in the join i have double quotes and square brackets…

 

What should i do to obtain aliases in lower case [mt] and not double quotes but only brackets like i wrote before : 
select * from [MyTable] [mt]
join                   [JoinedTable] [jt] on [jt].[foreign_key] = [mt].[primarey_key]

0

 Please set “Quoted identifiers” to “To lower” and disable “Use original case”.

There is issue related to extra quotes coming from completion: https://youtrack.jetbrains.com/issue/DBE-17221

Please follow it for updates.

0

Good Morning, Yaroslav, thanks for the help.

Problem is, when i set Quoted identifiers to “To lower”, then everything will be “To lower”, even the table names, and my databases are case sensitive, when i format the query.

Another problem is the suggestions on the joins are all lower case :

and when i format : (everything is lower case , table names, columns names…)

0

If you use completion, then you may set “Quoted identifiers” to “Do not change”.

 

0

If i understand, what i would like is impossible… 

table aliases in lower case, and everything (table, alias, columns) between bracket .

The settings seems pretty staightforward, but at the end it's confusing and nothing works as expected !

 

0

Currently it will work if you use completion suggestions. It's not possible to reformat existing code to desired style. Feel free to create feature request on YouTrack: https://youtrack.jetbrains.com/issues/DBE

0

MS SQL Server, MS Azure, I am fine with square brackets around auto generated table aliases, but I do not want quotes around them.  How do I turn it off?

0

Yes, good question though. I don't remember having those quotes before : “[alias]”

 

0

Nothing seems to change this behavior.  It eliminates the usefulness of auto generating aliases, since I have to spend more time cleaning up these quotes than typing the joins myself.

0

Please sign in to leave a comment.