News for hackers. Stuff that matters.
Re:Sqlfmt: an opinionated online SQL formatter by mjibson on Thursday September 27, 2018 @04:45PM (#18088472)
Author here. Based on feedback I am going to make a sqlfmt binary for easy editor integration.

You can currently already do this by using the CockroachDB binary (https://www.cockroachlabs.com/docs/releases/v2.1.0-beta.2018...) but understandably people want a more minimal solution.

Re:Sqlfmt: an opinionated online SQL formatter by egorfine on Thursday September 27, 2018 @05:47PM (#18089081)
Hey, thank you for the formatter! I really like the way it formats statements. Although I have found two issues:

1. It lowercases table and field names, rendering the formatted statement useless for a project with not exclusively lowercased names. Could you please fix this?

2. I'd appreciate accepting common placeholder "?" as a valid part of the SQL statement so that we can format queries with placeholders. Would that be possible?

Re:Sqlfmt: an opinionated online SQL formatter by mjibson on Thursday September 27, 2018 @05:53PM (#18089112)
The formatter adheres to CockroachDB rules which is why it acts like you describe. Case is insensitive in names unless you double quote it. Postgres-style (CockroachDB is one) uses "$1" for placeholders instead of "?". Adding "?" would complicate our grammar enough that it's not worth adding it.

sqlfmt is not super useful for non-postgres grammars.

Re:Sqlfmt: an opinionated online SQL formatter by egorfine on Friday September 28, 2018 @07:21AM (#18092509)
I understand it about placeholders. Fair enough. I can do quick s/\?/\$1/g, no prob.

Still how about not lowercasing identifiers? This is actually a blocker, I'm sure you see it:)

Re:Sqlfmt: an opinionated online SQL formatter by crooked-v on Thursday September 27, 2018 @08:46PM (#18090144)
Consider those of us stuck with Java adapters to Postgres, which means Postgres syntax but ? for placeholders.
Re:Sqlfmt: an opinionated online SQL formatter by mjibson on Thursday September 27, 2018 @10:45PM (#18090596)
Is that a thing? The Java driver must actually parse those and convert them. Java is crazy. https://github.com/mjibson/sqlfmt/issues/25 is the issue to track '?' as placeholders.
Re:Sqlfmt: an opinionated online SQL formatter by lilactown on Friday September 28, 2018 @01:40AM (#18091308)
It might be crazy, but having just gotten my hands dirty with some seriously DB programming, JDBC has a hell of a lot of value in my view.
Re:Sqlfmt: an opinionated online SQL formatter by rntksi on Friday September 28, 2018 @06:43AM (#18092336)
Hey! I love your tool.

Any chance of allowing keywords that are specific to a SQL implementation? (e.g. PostgreSQL)

If I enter "CREATE MATERIALIZED VIEW ... WITH DATA;" in for example, it would tell me "materialized" and "with data" is wrong.

Re:Sqlfmt: an opinionated online SQL formatter by mjibson on Friday September 28, 2018 @02:51PM (#18095991)
As CockroachDB matures these kinds of things will slowly get added.

But sqlfmt doesn't (currently) have a goal to format all SQL, just cockroach SQL.

Re:Sqlfmt: an opinionated online SQL formatter by morenoh149 on Thursday September 27, 2018 @11:25PM (#18090776)
I thought it was a ploy to get people to install cockroach, that's what I'm doing now.