News for hackers. Stuff that matters.
Re:Sqlc: Compile SQL to type-safe code by Nugget0 on Tuesday September 10, 2024 @02:29AM (#41497775)
This is what jOOQ does. Best SQL library I've ever used. https://www.jooq.org/
Re:Sqlc: Compile SQL to type-safe code by cies on Tuesday September 10, 2024 @03:51AM (#41498268)
We use jOOQ, and love it. But sqlc also makes nice trade offs. I see it does Kotlin generation: if this lib was around when we picked jOOQ, I's certainly had considered it.

Differences:

* jOOQ is an eDSL with an optional schema-to-classes generator

* you write jOOQ queries in Java (or Kotlin as we do)

* there's quite a bit of type-safety added when using the generator: the schema needs to be match the queries you write or you get compile errors

* jOOQ queries are built are run time adding a little overhead that sqlc does not

* writing jOOQ is very close writing SQL (a very thin abstraction), sqlc is "just SQL" it seems

Re:Sqlc: Compile SQL to type-safe code by refset on Tuesday September 10, 2024 @03:56AM (#41498295)
Yep sqlc is more akin to Kotlin's SQLDelight https://github.com/cashapp/sqldelight
Re:Sqlc: Compile SQL to type-safe code by cies on Tuesday September 10, 2024 @04:02AM (#41498338)
That's a really nice project indeed. We looked at it I remember, when we pciked jOOQ, but it was too new to bet the farm on back then. It progressed really nicely.
Re:Sqlc: Compile SQL to type-safe code by refset on Tuesday September 10, 2024 @04:28AM (#41498513)
Building on top of IntelliJ's parser and 'PSI' stack as a headless engine sounds slightly mad at first but seems to provide a lot of leverage, as demonstrated by the number of dialects the team is able to support via mixins. By contrast sqlc appears to require a lot of code to support each additional dialect.