Sqlc: Compile SQL to type-safe code
61–70 of 109 posts
Re: Sqlc: Compile SQL to type-safe code
#62Earlier quoted context omitted.
Yep sqlc is more akin to Kotlin's SQLDelight https://github.com/cashapp/sqldelight
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
#63There was a saying that before learning postgres in depth, the db is just a dumb store of data for devs, once you spend time to learn the tools it provides though, most applications just look like a very thin layer on top of the sql. There is so much more to rdbms (especially pg) than just joins - common table expressions, window functions, various views, let alone all the extensibility - extensions, custom types, ev…
I keep hearing about how powerful pg is. It would be great to see an example application that uses all it's features.
Re: Sqlc: Compile SQL to type-safe code
#64Surprised nobody has mentioned “Kysely” ( https://kysely.dev ). It is a query builder (not an ORM), that (ab)-uses the Typescript type system to give you full type safety, intellisense, autocomplete etc. Crucially it doesn’t require any build/compile step for your queries which is fantastic.
I had a look. It says it's type safe but I see strings everywhere. It seems the IDE can autocomplete the strings, but does that count as type safety nowadays? (How does the IDE do the autocomplete on strings? Will the compiler also catch "bad strings"?) Otherwise it looks much like jOOQ but without the "jOOQ generator" (which adds most of the type safety).
Re: Sqlc: Compile SQL to type-safe code
#65Surprised nobody has mentioned “Kysely” ( https://kysely.dev ). It is a query builder (not an ORM), that (ab)-uses the Typescript type system to give you full type safety, intellisense, autocomplete etc. Crucially it doesn’t require any build/compile step for your queries which is fantastic.
I had a look. It says it's type safe but I see strings everywhere. It seems the IDE can autocomplete the strings, but does that count as type safety nowadays? (How does the IDE do the autocomplete on strings? Will the compiler also catch "bad strings"?) Otherwise it looks much like jOOQ but without the "jOOQ generator" (which adds most of the type safety).
Re: Sqlc: Compile SQL to type-safe code
#66Earlier quoted context omitted.
It would be great to have some sort of sql string to type parsing as some sort of plugin to TypeScript.
Didn’t use myself, but AFAIK slonik library is doing what you’ve described: https://github.com/gajus/slonik
Re: Sqlc: Compile SQL to type-safe code
#67Coincidentally, we just released support for this in Prisma a few weeks ago: https://www.prisma.io/blog/announcing-typedsql-make-your-raw...
Re: Sqlc: Compile SQL to type-safe code
#68Surprised nobody has mentioned “Kysely” ( https://kysely.dev ). It is a query builder (not an ORM), that (ab)-uses the Typescript type system to give you full type safety, intellisense, autocomplete etc. Crucially it doesn’t require any build/compile step for your queries which is fantastic.
I had a look. It says it's type safe but I see strings everywhere. It seems the IDE can autocomplete the strings, but does that count as type safety nowadays? (How does the IDE do the autocomplete on strings? Will the compiler also catch "bad strings"?) Otherwise it looks much like jOOQ but without the "jOOQ generator" (which adds most of the type safety).
there is kysely-codegen which generates types based on the actual database schema.
Re: Sqlc: Compile SQL to type-safe code
#69Have been enjoying go-jet that takes a different approach: analyzes the tables in your DB and generates a set of Golang structs that lets you write 100% Golang code that looks like 99% SQL. Genius! https://github.com/go-jet/jet
JET doesn't support typesafe result mapping, or typesafe table joins, I believe. And it's not possible to do that in Go without some heavy-handed code generation. A better comparison is probably Hibernate and QueryDSL in Java.
Re: Sqlc: Compile SQL to type-safe code
#70I don't work with Go, but this seems like a dream. I really like the SQLx query macros in Rust. I would love for something like this
We don't need to generate code and we get the same type safety from queries written in plain SQL.
If anything, I wish there was a SQLx in other languages I have to support.