TaoK / PoorMansTSqlFormatter

A small free .Net and JS library (with demo UI, command-line bulk formatter, SSMS/VS add-in, notepad++ plugin, winmerge plugin, and demo webpage) for reformatting and coloring T-SQL code to the user's preferences.
http://www.architectshack.com/PoorMansTSqlFormatter.ashx
GNU Affero General Public License v3.0
969 stars 268 forks source link

DBeaver integration with PoorManSQL #285

Closed davidtessier closed 1 year ago

davidtessier commented 1 year ago

Hey there,

I use DBeaver and have been trying to point to the command line version of PoorMans formatter but I have not been able to get it to work. I'm wondering what I have to do for this?

I set the external formatter command line to "C:\SqlFormatter.1.6.10\SqlFormatter.exe" ${file} which is my best guess. I've tried some other formats like alternating the slashes, removing quotes, but nothing works.

I am not presented with an error, it just hangs for a moment, and then the code doesn't change.

Any help on this would be great! I'm running Windows 11 with DBeaver v23.0.0.x

2023-03-08 11_41_21-Preferences

milan-stoj commented 1 year ago

@davidtessier I was able to get this working. Remove the quotes around the path to SqlFormatter.exe. For example, this is what I have:

C:\SqlFormatter.1.6.10\SqlFormatter.exe ${file}

davidtessier commented 1 year ago

@davidtessier I was able to get this working. Remove the quotes around the path to SqlFormatter.exe. For example, this is what I have:

C:\SqlFormatter.1.6.10\SqlFormatter.exe ${file}

Thanks for the reply! I tried this and I get the same experience as before.

If I run the following in a command prompt, it works.

c:\PoormanSQL>SqlFormatter.exe "C:\Users\dave\OneDrive\DBeaver Projects\Project\Scripts\script.sql"

I'm wondering if it has something to do with my scripts living in a path that has spaces.

milan-stoj commented 1 year ago

Hmm, I'm noticing now too that formatting commands are not recognized when using the Use temp file setting. Try unchecking the Use temp file checkbox, and remove the ${file} variable from the command. Then put whatever formatting parameters you want after the path, like this:

C:\path\to\SqlFormatter.exe -st 4 -mw 80 -sb 2 -cb 1 -sac -ebc -sk -uk -eil -ecl -ecs -ebe

This works for me. No quotes necessary.

davidtessier commented 1 year ago

x

That did it! The formatter is now working perfectly! Thank you so much.