Formatting SQL Code in PhpStorm

With datagrip, a CTRL ALT L reformats my SQL code nicely

However, it does nothing in PhpStorm even though mysql code style shows the following:

SELECT T.Entity_Id,
T.`Name` "Entity_Name",
T.`Note` "Entity Remarks",
V.`References` "Other_References",
V.Status "The_Status"
FROM Main_Table T,
Special_View V
WHERE T.Entity_Id = V.Ref_Id
ORDER by 1, 4 desc

What am I missing?

Thanks,

dmd

0

Code style for SQL in PhpStorm is configured at File | Settings | Editor | Code Style | SQL. Could you please clarify what's wrong with the attached code piece?

0

Dmitry,

Maybe I don't understand what is going on.  When I look at Editor > Code Style > SQL > MySQL there are numerous pages that appear to have default values set.

I see virtually the same thing in datagrip.

The problem is that when I reformat a document using CTRL ALT L nothing happens to the SQL code.

However, with datagrip CTRL ALT L reformats the SQL nicely.  With PHPStorm, nothing changes.

Thanks,

Dave

 

0

As far as I am aware, CTRL ALT L does not format SQL code in the standard editor window. You have to choose 'Edit MySQL Fragment' from the Quick Fix menu (ALT+ENTER) then press CTRL+ALT+L in the new frame it opens. This will reformat the SQL, but it does so in isolation, so it does not indent it with the other code on the page :-(

If anyone knows of a better/quicker way to do this, PLEASE let me know!

1

Dave, does any message appear when you hit Ctrl+Shift+L? It's supposed to say that the code is properly formatted already if there's nothing to change: https://recordit.co/FjdXaVlR6X

Also, following Scott's thought, are you reformatting an .sql file or some other file type that has SQL injected?

 

Scott Goddard, unfortunately, no, there no other way. Please vote: https://youtrack.jetbrains.com/issue/IDEA-146806
0

请先登录再写评论。