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

fix(codegen/golang): Use int8 for MySQL TINYINT #3298

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions internal/codegen/golang/mysql_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,22 @@ func mysqlType(req *plugin.GenerateRequest, options *opts.Options, col *plugin.C
} else {
if notNull {
if unsigned {
return "uint32"
return "uint8"
}
return "int32"
return "int8"
}
return "sql.NullInt32"
// The database/sql package does not have a sql.NullInt8 type, so we
// use the smallest type they have which is NullInt16
return "sql.NullInt16"
}

case "smallint", "year":
case "year":
if notNull {
return "int16"
}
return "sql.NullInt16"

case "smallint":
if notNull {
if unsigned {
return "uint16"
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.

2 changes: 1 addition & 1 deletion internal/endtoend/testdata/json/mysql/go/copyfrom.go

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

2 changes: 1 addition & 1 deletion 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.

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

Loading