Skip to content

Commit

Permalink
fix(codegen/golang): BREAKING: Use int16 for MySQL SMALLINT and `…
Browse files Browse the repository at this point in the history
…YEAR` (#3106)

Resolves #3088
  • Loading branch information
andrewmbenton committed Jan 5, 2024
1 parent 8d68872 commit 8a58933
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
11 changes: 10 additions & 1 deletion internal/codegen/golang/mysql_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,16 @@ func mysqlType(req *plugin.GenerateRequest, options *opts.Options, col *plugin.C
return "sql.NullInt32"
}

case "int", "integer", "smallint", "mediumint", "year":
case "smallint", "year":
if notNull {
if unsigned {
return "uint16"
}
return "int16"
}
return "sql.NullInt16"

case "int", "integer", "mediumint":
if notNull {
if unsigned {
return "uint32"
Expand Down
6 changes: 3 additions & 3 deletions internal/endtoend/testdata/datatype/mysql/go/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions internal/endtoend/testdata/vet_explain/mysql/db/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions internal/endtoend/testdata/vet_explain/mysql/db/query.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8a58933

Please sign in to comment.