Skip to content
Discussion options

You must be logged in to vote

For the override shown, the missing piece is nullable: true. A db_type override defaults to matching non-nullable columns, so it won't replace the type of a nullable column that would otherwise become sql.NullInt32.

For a nullable, signed MySQL INT, put this under your Go generation settings (v2 configuration):

version: "2"
sql:
  - engine: "mysql"
    schema: "schema.sql"
    queries: "query.sql"
    gen:
      go:
        package: "db"
        out: "db"
        overrides:
          - db_type: "int"
            nullable: true
            go_type:
              type: "int"
              pointer: true

Adapt the paths/package to your existing configuration, then regenerate. The explicit ove…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by astro-cosmo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants