Live data from Hacker News

Sqlfmt: an opinionated online SQL formatter

cockroachlabs.com

11–20 of 94 posts

Re: Sqlfmt: an opinionated online SQL formatter

#11

If you're working with something close to PostgreSQL syntax support, why wouldn't you start with pgFormatter ( http://sqlformat.darold.net/ )? It's been around for awhile and I can't see anything new or substantially more advanced in the proposed solution. I have to say, I do most of my development work in the database, and I'm not thrilled with any of the automatic formatters thus far. The ones I've seen can do a go…

pgFormatter formats

  SELECT 1, 2
as

  SELECT
      1,
      2
which is one of the core complaints the article addresses.

Re: Sqlfmt: an opinionated online SQL formatter

#12
post #10
post #7

standalone Query parser would be nice :)

In case you're looking for something Postgres syntax compatible, and find cgo acceptable: https://github.com/lfittl/pg_query_go (this uses the actual Postgres parser wrapped into a library)

Wow nice thank you for pointing it out!

Re: Sqlfmt: an opinionated online SQL formatter

#13

If you're working with something close to PostgreSQL syntax support, why wouldn't you start with pgFormatter ( http://sqlformat.darold.net/ )? It's been around for awhile and I can't see anything new or substantially more advanced in the proposed solution. I have to say, I do most of my development work in the database, and I'm not thrilled with any of the automatic formatters thus far. The ones I've seen can do a go…

pgFormatter formats SELECT 1, 2 as SELECT 1, 2 which is one of the core complaints the article addresses.

That actually seems like a relatively minor complaint on the order of submitting a pull request to an existing fairly good project (as is pgFormatter) rather than coming up with standard 15 for SQL formatting in a new tool. An option where, if the column text doesn't overrun a column limit, is single line and then split once it does overrun doesn't sound like a bad feature, but it does sound like a small one.

(addition) More than anything that's wrong with all of these formatters for SQL is that there real consensus for what good formatting is. There are historical norms for sure, and that's likely a starting point, but reconciliation between the communities around each database vendor (and sometimes each company developing with that database) make that a difficult challenge. So this new tool will become the CockroachDB formatter, pgFormatter is as far as I know the most popular PostgreSQL formatter, other databases your mileage will vary. Each not really an SQL formatter, but an SQL formatter for (stick affinity here). For CockroachDB, I'm not sure how much payoff there is for moving away from the more popular tool for Postgres if they're stressing their similarity to PostgreSQL SQL.

Re: Sqlfmt: an opinionated online SQL formatter

#14
I’d love it if StackOverflow would let me select code text and automatically reformat it according to some standard spec (I don’t care which set of opinions are used provided it’s readable!) - too many inexperienced (or unqualified, it seems) people copy and paste ad-hoc written SQL that I always have to manually reformat myself when I edit their questions for readability.

Re: Sqlfmt: an opinionated online SQL formatter

#15

Earlier quoted context omitted.

pgFormatter formats SELECT 1, 2 as SELECT 1, 2 which is one of the core complaints the article addresses.

That actually seems like a relatively minor complaint on the order of submitting a pull request to an existing fairly good project (as is pgFormatter) rather than coming up with standard 15 for SQL formatting in a new tool. An option where, if the column text doesn't overrun a column limit, is single line and then split once it does overrun doesn't sound like a bad feature, but it does sound like a small one. (additi…

It sounds like this formatter is sufficiently different in its approach (based on the prettier paper) that a PR would basically rewrite the existing one?

Re: Sqlfmt: an opinionated online SQL formatter

#17
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

#19
Brief question, only tangentially related:

Is it me or is "opinionated" software popping up all over the place? It looks to me like the author considers it a selling point, too.

Can someone explain to me why I would want an "opinionated" software over any regular old software? Especially over a configurable software?

I'm not a native speaker, but I never encountered "opinionated" being used with positive connotation. It has so far always been in the "well, uh, he's very opinionated!" sense of apologizing for that old grumpy person who gets on everybody's nerves.

Re: Sqlfmt: an opinionated online SQL formatter

#20
post #19

Brief question, only tangentially related: Is it me or is "opinionated" software popping up all over the place? It looks to me like the author considers it a selling point, too. Can someone explain to me why I would want an "opinionated" software over any regular old software? Especially over a configurable software? I'm not a native speaker, but I never encountered "opinionated" being used with positive connotation.…

There was a trend recently of "unopinionated" software, where it has a ton of options to do exactly what you want. The problem was, it took a long time to configure it, and development was slow because every variant and option had to be tested.

To me, "opinionated" is shorthand for "not a lot of options", so it is less extensible, but will probably also work better and right out of the box.

Post reply on HN