IntelliJ IDEA cannot format SQL code properly
Asked Answered
G

2

5

I have reinstalled the last version of IntelliJ IDEA and then when I try to format an SQL file, it orders all the lines as shown on the image.

My SQL file

However, I have not made any settings for SQL formatting in the previous versions and the format was OK as shown on my current setting preview as shown below:

My current settings

So, is there anything default to format SQL properly? There are lots of choices in the settings, but I just want to use a default one available on the settings (I tried but it format almost the same).

Gradualism answered 22/4, 2022 at 18:2 Comment(5)
@nameless_horse any reply about the format?Gradualism
1) This could be some 1-time glitch. Try restarting your computer -- sometimes this helps. 2) Try disabling all custom (not bundled by default) plugins. Any difference? 3) Try File | Repair IDE -- it has multiple steps and one of them may help. 4) If still nothing: try resetting your Settings to defaults: File | Manage IDE Settings | Restore Default Settings... -- it can make a backup before doing that.Unholy
P.S. You can copy your real code and paste it into the Code Style preview area. Will it format it there OK? Maybe it's something wrong with the file.Unholy
@Unholy Thanks a lot amigo. Your detailed answer is really helpful and I will give a try for all the steps you mentioned. At least, I see that there is no problem regarding to default settings, and as before, I do not need anything special to format sql code.Gradualism
Any update on this? I am getting this glitchGabbro
I
6

I faced the same issue. Settings/Languages&Frameworks/SQL Dialects, there you can find the dialect of the file. Change it to what you use.

That's how I solved the problem, even though you apply global or project SQL Dialect, the file may not be updated.

enter image description here

As you can see from the image, Generic SQL causes the problem.

Ionization answered 30/11, 2022 at 9:13 Comment(0)
R
0

For me, it works to disable the 'Line breaks' option in the 'Wrapping' tab

Configuration option disable

Ragamuffin answered 22/4 at 17:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.