-
Notifications
You must be signed in to change notification settings - Fork 459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SQL Formatter #156
Comments
The hibernate parser can't handle multiple SQL statements, e.g. ALTER TABLE userinfo ALTER COLUMN id drop DEFAULT;
ALTER TABLE userinfo drop constraint userinfo_pkey cascade; We could try to detect the It looks like the best opensource SQL prettifiers that can handle multiple statements are:
Writing to disk and spawning a VM for every call to |
There is also a sql formatter implemented in dbeaver: I don't know if it can be reused. |
Thanks! Can't tell if it supports multiple SQL statements or not, and it's not published to maven central. We could maybe copy-paste the code and give credit. They also have support for external formatters, so it appears that they don't love their own implementation. |
I'm not sure but I use this formatter in dbeaver itself and it work well for me. |
A PR would be great! I added the skeleton of SQL support in the PR above, I would start from there. Be sure to read the contrib guide as well. If you can copy DBeaver's implementation over without any deps, then it can go in I would double-check that DBeaver can support multiple SQL statements. If it doesn't support multiple SQL statements in one file, would it still work for you? It wouldn't for me, but if it's enough for you I'm all for it :) |
Released in |
I'd ilke a SQL formatter (specifically for formatting Flyway db migration scripts). Hibernate has BasicFormatterImpl and DDLFormatterImpl. They don't do a ton, but they're better than nothing.
The General SQL Parser is really neat, but there's no free version we can distribute. Maaaaybe they'd be interested in publishing a "format-only" version along with our lib? Might be a marketing opportunity for them. I'll email them and invite them to this thread.
Regardless, there are different ways that folks might wanna format sql, but there isn't a language-specific plugin to hang onto like there has been scala, kotlin, gradle, etc.
Here's my proposal:
If General SQL Parser is interested, we could maybe have something like this:
The text was updated successfully, but these errors were encountered: