SQL Indentation Not Working Properly
When I select to change the indentation in Settings > Editor > Code Style > SQL > General, nothing happens in the preview pane, nor does toggling tabs or changing tab/spacing sizes. When I disable formatting, the preview pane does switch to show tabs. See below for screenshots.


Also, even though I'm using the "Project" scheme, it does the same thing when I switch back to "Default" and try changing it. Additionally, when I try to format a file that only has SQL in it, it converts my tabs to spaces. All my SQL dialects are set to "Inherit general SQL style". Here's a pre-formatted .sql file:

Post-formatted:

I've confirmed that I do not have an .editorconfig in my project, and this is also happening to me in DataGrip. Any thoughts on how to solve? As a side note, I did just enable Settings Sync on my JetBrains IDEs today and I can't recall if this was working beforehand and disabling it does nothing to help resolve this issue.
请先登录再写评论。
Could you try adding *.sql extension to SQL file type in Settings (Ctrl + Alt + S) > Editor > File Types > SQL: https://i.imgur.com/9hF9RHD.png
Thanks for the quick reply! I've checked and the *.sql extension is already included in the SQL file type.

Ok, could you please try following:
If none of the above help - please provide your IDE logs (Help > Collect Logs and Diagnostic Data) and IDE Settings (File > Manage IDE Settings > Export Settings..). You can upload both zip files here: https://uploads.jetbrains.com, and provide the uploaded file ID. Thanks!
Ivan, thanks for your continued support and assistance.
There wasn't a SQL dialect for the file I was working with. I went through the seven or eight steps for the Repair IDE option and no success. I then disabled all plugins, bundled and 3rd party, but couldn't see the SQL styling in the Editor > Code Style menu. After re-enabling just the Database Tools and SQL plugin, I checked the code style for SQL > General and the tabs still didn't display in the preview pane (or work in the file I was using).
I've re-enabled all plugins and uploaded the IDE logs & IDE Settings to the URL you posted. The uploaded file ID is: 2023_03_31_KsQtKEFG4TNDfGb2xUJqGc. If you would like to see the logs with just the Database Tools and SQL plugin enabled, I can provide those as well.
Actually, I'll just go ahead and give you the logs with just the Database Tools and SQL plugin enabled. It is uploaded file ID: 2023_03_31_3pqcU6Jg6wJRfbxx4jWZib.
Thank you!
Ok, thank you for the information. I didn't notice you are using project scheme code styles instead of IDE (default) code style settings, this is why I asked you for the IDE settings export, but seems they are not related to your case.
That is why we need to troubleshoot your project level code style settings:
As for the issue with SQL code style preview pane - it was already reported: https://youtrack.jetbrains.com/issue/DBE-17299
You can vote for it and follow its progress.
Gotcha - I was trying with both the Default IDE settings and the project ones. So, I've followed the steps you suggested and still no luck on *.sql files. I did do the following just to see if it was more code style than just the SQL ones:
I've uploaded my .idea folder (with the code styles folder renamed as you suggested). The uploaded file ID is 2023_03_31_WpdGPSKmH9JbJCKDqr28Jp.
Lastly, thanks for pointing me in the direction of that issue! I couldn't tell if the preview pane was influencing the actual formatting and causing the problem or vice versa, but I've voted for the issue and will watch it.
Thanks for the .idea folder. I tried to reproduce your issue with it, but couldn't.
Is your .idea/codeStyles folder recreated after renaming the old one to codeStylesOld? In the .idea folder you shared, I can only see the renamed folder.
Also, if you try to set the 'Default' scheme in Settings > Editor > Code Style > SQL > General and enable/disable Use tab character, does it reflect in the editor when reformatting .sql file: https://i.imgur.com/JyIVst2.gif ? Basically, to determine if it is behaving the same for Project and Default (IDE) scheme.
Ivan - I appreciate your patience while I take a bit to respond. I still haven't figured out the problem, but I made some progress. Let me answer your post first.
The .idea/codeStyles folder didn't get recreated after renaming the old one. Maybe I needed to close IntelliJ first? I also tried changing to the 'Default' theme and working with it for still no luck. Here's what I tried next.
I opened a new test project and confirmed formatting a SQL file just like in the GIF you shared, and the formatting worked. So, I removed all IntelliJ-related files from my project to see what was causing the issue. Everything worked until I tried to select a SQL dialect for my .sql files. When I changed from "General SQL" to "PostgreSQL", my formatting selections were forgotten. Switching back to my test project I could reproduce the same issue, despite my Settings > Editor > Code Style > SQL > PostgreSQL, Greenplum, Redshift option Inherit general SQL style being ticked.
Maybe the language-specific options are somehow ignoring the "inherit" and are being used themselves? I confirmed that unticking the Inherit general SQL style box for PostgreSQL formatted my test file correctly.
P.S. If you can point me to a good way to record and upload like you do, I'll get a recording to share.
Kburnett
Thanks for the detailed feedback.
I managed to reproduce your issue in IntelliJ 2023.1. It seems indeed it is a known regression: https://youtrack.jetbrains.com/issue/DBE-17793. I checked in 2022.3.3 (previous release) and it works as expected.
You can vote for the original issue and follow its progress.
In the meantime you can disable inheritance and use code style of Postgres dialect as you already mentioned.
It is an open source screenshot tool called ShareX. It automatically uploads screenshots, gifs and screen recordings to image hosting service.
Ivan - sounds good, and will do! Thank you for your help, and I'll move forward with what you suggested. Thank you also for the tool recommendation!