Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sqlc): Support custom generic nullable types (e.g. sql.Null) #3279

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gregoryjjb
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support sql.Null
1 participant