feat(sqlc): Support custom generic nullable types (e.g. `sql.Null`)
Support wrapping any nullable field with a generic type provided by the user. The config looks like this:
sql:
- gen:
go:
...
generic_null_type:
import: "database/sql"
type: "Null"
and the generated models look like this:
type Foo struct {
ID int64
SometimesBlankText sql.Null[string]
SometimesBlankNumeric sql.Null[int64]
}
Adds github.com/LukaGiorgadze/gonull to testdata since the module isn't on Go 1.22 yet and thus can't use database/sql.Null. Upgrading it to 1.22 would probably be cleaner.
Supersedes #3202, closes #3149
When is this feature planned to be merged?
Are there any show stoppers ? @kyleconroy
Hi, I rebased Grag's feature branch to sqlc actual main and resolved conflicts here https://github.com/tomas-mraz/sqlc.git. Can you @gregoryjjb rebase on your side to solve PR conflicts? To easily solve conflicts during rebase, you can just copy /internal/codegen/golang/mysql_type.go from my fork. Nice day