From the article: > I’ve largely covered sqlc’s objective benefits and features, but more subjectively, it just feels good and fast to work with. Like Go itself, the tool’s working for you instead of against you, and giving you an easy way to get work done without wrestling with the computer all day. I've been meaning to write a blog post about sqlc myself, and when I get to it, I'll probably quote this line. sqlc is…
A few years ago I had spent a year working with a Go project that made heavy use of one of the (then) popular Go ORMs. Learned my lesson, never again. Magic=Bad.
How We Went All In on sqlc/pgx for Postgres and Go
121–130 of 160 posts
Re: How We Went All In on sqlc/pgx for Postgres and Go
#122From the article: > I’ve largely covered sqlc’s objective benefits and features, but more subjectively, it just feels good and fast to work with. Like Go itself, the tool’s working for you instead of against you, and giving you an easy way to get work done without wrestling with the computer all day. I've been meaning to write a blog post about sqlc myself, and when I get to it, I'll probably quote this line. sqlc is…
Can it help with migrations? Seeing it has the field definitions right there it should at least be possible.
Otherwise I can see how a system like this could become quite complex over time as the database structure changes.
Re: How We Went All In on sqlc/pgx for Postgres and Go
#123Earlier quoted context omitted.
Yes, I was about to reply to myself with a link to this issue as I couldn't see anything in official docs unless looking at the github issues. https://github.com/kyleconroy/sqlc/issues/1157
But it seems like this discussion is about the lack of support for null values in enum types in joins (not joins in general). Am I missing something?
Re: How We Went All In on sqlc/pgx for Postgres and Go
#124From the article: > I’ve largely covered sqlc’s objective benefits and features, but more subjectively, it just feels good and fast to work with. Like Go itself, the tool’s working for you instead of against you, and giving you an easy way to get work done without wrestling with the computer all day. I've been meaning to write a blog post about sqlc myself, and when I get to it, I'll probably quote this line. sqlc is…
> code generation, instead of e.g. reflection "Hey man, we noticed there's not enough compiler in your compiler, so we made a second compiler for your compiler."
Re: How We Went All In on sqlc/pgx for Postgres and Go
#125Earlier quoted context omitted.
Working with SQL in X (any language) usually has a poor developer experience that is why ORM or query builders are popular. Things like proper syntax highlight or type safety (I remain to be convinced that sqlc can really check the validity at compile, usually it only works in specific basic cases). You just have to choose wisely your tools for sure, but most of the code you write needs to be rewritten anyway every X…
> Working with SQL in X (any language) usually has a poor developer experience that is why ORM or query builders are popular. At least when it comes to Postgres, I don't understand why more developers don't create their own user-defined functions with PL/pgSQL. It's very a robust and powerful procedural language. In my opinion, ORM's like SQLAlchemy add a completely unnecessary layer of abstraction. ORMs might be con…
Re: How We Went All In on sqlc/pgx for Postgres and Go
#126 -- name: ListAuthors :many
SELECT * FROM authors
ORDER BY name;
and in Go I can then say `authors, err := queries.ListAuthors(ctx)`. This is cool. Now, if I want to "get a list of American authors" I would write: -- name: ListAuthorsByNationality :many
SELECT * FROM authors
WHERE nationality = $1;
and in Go I can then say `americanAuthors, err := queries.ListAuthorsByNationality(ctx, "American")`. Now, if I want to "get a list of American authors that are dead", I would have to write: -- name: ListDeadAuthorsByNationality :many
SELECT * FROM authors
WHERE nationality = $1 AND dead = 1;
... I like the idea of getting Go structs that represent table rows, but I don't want to keep a record of every query variation I may need to execute in Go code. I want to write in Go: deadAmericanAuthors, err := magic.GetAuthorsBy(Params{
Nationality: "American",
Dead: true
})
without having to write manually the N potential sql queries that the above code may represent.Re: How We Went All In on sqlc/pgx for Postgres and Go
#127Earlier quoted context omitted.
Being translated means it doesn't have the normal cgo calling overhead. It also means you can cross compile it for every platform that the Go toolchain supports without any external compilers.
Nope, note their readme says: These combinations of GOOS and GOARCH are currently supported darwin amd64, darwin arm64, freebsd amd64, linux 386, linux amd64, linux arm, linux arm64, windows amd64 and if you look at their source tree https://gitlab.com/cznic/sqlite/-/tree/master/lib you can see they have sqlite_darwin_amd64.go sqlite_darwin_arm64.go sqlite_freebsd_amd64.go sqlite_linux_386.go sqlite_linux_amd64.go sq…
Re: How We Went All In on sqlc/pgx for Postgres and Go
#128Re: How We Went All In on sqlc/pgx for Postgres and Go
#129From the article: > I’ve largely covered sqlc’s objective benefits and features, but more subjectively, it just feels good and fast to work with. Like Go itself, the tool’s working for you instead of against you, and giving you an easy way to get work done without wrestling with the computer all day. I've been meaning to write a blog post about sqlc myself, and when I get to it, I'll probably quote this line. sqlc is…
> code generation, instead of e.g. reflection "Hey man, we noticed there's not enough compiler in your compiler, so we made a second compiler for your compiler."
Re: How We Went All In on sqlc/pgx for Postgres and Go
#130From the article: > I’ve largely covered sqlc’s objective benefits and features, but more subjectively, it just feels good and fast to work with. Like Go itself, the tool’s working for you instead of against you, and giving you an easy way to get work done without wrestling with the computer all day. I've been meaning to write a blog post about sqlc myself, and when I get to it, I'll probably quote this line. sqlc is…
It does indeed look promising! Can it help with migrations? Seeing it has the field definitions right there it should at least be possible. Otherwise I can see how a system like this could become quite complex over time as the database structure changes.