-
-
Notifications
You must be signed in to change notification settings - Fork 47
Open
Description
Lines 188 to 202 in ef8f762
| case schema.Int, schema.Uint: | |
| var sqlType string | |
| switch { | |
| case field.Size < 16: | |
| sqlType = "smallint" | |
| case field.Size < 31: | |
| sqlType = "int" | |
| default: | |
| sqlType = "bigint" | |
| } | |
| if field.AutoIncrement { | |
| return sqlType + " IDENTITY(1,1)" | |
| } | |
| return sqlType |
Because in SQL Server, the range of values for the tinyint type is from 0 to 255, which exactly matches the range of uint8, so when field.Size < 16 and field.DataType == schema.Uint, should sqlType be tinyint? Like this:
case schema.Int, schema.Uint:
var sqlType string
switch {
case field.Size < 16:
if field.DataType == schema.Uint {
sqlType = "tinyint"
} else {
sqlType = "smallint"
}
case field.Size < 31:
sqlType = "int"
default:
sqlType = "bigint"
}
if field.AutoIncrement {
return sqlType + " IDENTITY(1,1)"
}
return sqlTypeMetadata
Metadata
Assignees
Labels
No labels