Fix DBMetas returned unsigned tinyint #2017
|
@ -263,6 +263,7 @@ func (db *mysql) SetParams(params map[string]string) {
|
|||
|
||||
func (db *mysql) SQLType(c *schemas.Column) string {
|
||||
var res string
|
||||
var isUnsigned bool
|
||||
switch t := c.SQLType.Name; t {
|
||||
case schemas.Bool:
|
||||
res = schemas.TinyInt
|
||||
|
@ -309,8 +310,19 @@ func (db *mysql) SQLType(c *schemas.Column) string {
|
|||
res = schemas.Text
|
||||
case schemas.UnsignedInt:
|
||||
res = schemas.Int
|
||||
isUnsigned = true
|
||||
case schemas.UnsignedBigInt:
|
||||
res = schemas.BigInt
|
||||
isUnsigned = true
|
||||
case schemas.UnsignedMediumInt:
|
||||
res = schemas.MediumInt
|
||||
isUnsigned = true
|
||||
case schemas.UnsignedSmallInt:
|
||||
res = schemas.SmallInt
|
||||
isUnsigned = true
|
||||
case schemas.UnsignedTinyInt:
|
||||
res = schemas.TinyInt
|
||||
isUnsigned = true
|
||||
default:
|
||||
res = t
|
||||
}
|
||||
|
@ -329,7 +341,7 @@ func (db *mysql) SQLType(c *schemas.Column) string {
|
|||
res += "(" + strconv.Itoa(c.Length) + ")"
|
||||
}
|
||||
|
||||
if c.SQLType.Name == schemas.UnsignedBigInt || c.SQLType.Name == schemas.UnsignedInt {
|
||||
if isUnsigned {
|
||||
res += " UNSIGNED"
|
||||
}
|
||||
|
||||
|
|
|
@ -217,8 +217,9 @@ func (db *sqlite3) SQLType(c *schemas.Column) string {
|
|||
case schemas.Char, schemas.Varchar, schemas.NVarchar, schemas.TinyText,
|
||||
schemas.Text, schemas.MediumText, schemas.LongText, schemas.Json:
|
||||
return schemas.Text
|
||||
case schemas.Bit, schemas.TinyInt, schemas.SmallInt, schemas.MediumInt, schemas.Int, schemas.Integer, schemas.BigInt,
|
||||
schemas.UnsignedBigInt, schemas.UnsignedInt:
|
||||
case schemas.Bit, schemas.TinyInt, schemas.UnsignedTinyInt, schemas.SmallInt,
|
||||
schemas.UnsignedSmallInt, schemas.MediumInt, schemas.Int, schemas.UnsignedInt,
|
||||
schemas.BigInt, schemas.UnsignedBigInt, schemas.Integer:
|
||||
return schemas.Integer
|
||||
case schemas.Float, schemas.Double, schemas.Real:
|
||||
return schemas.Real
|
||||
|
|
|
@ -218,7 +218,7 @@ func (parser *Parser) parseFieldWithTags(table *schemas.Table, fieldIndex int, f
|
|||
col.SQLType = schemas.Type2SQLType(field.Type)
|
||||
}
|
||||
if ctx.isUnsigned && col.SQLType.IsNumeric() && !strings.HasPrefix(col.SQLType.Name, "UNSIGNED") {
|
||||
col.SQLType.Name = col.SQLType.Name + " UNSIGNED"
|
||||
col.SQLType.Name = "UNSIGNED " + col.SQLType.Name
|
||||
}
|
||||
|
||||
parser.dialect.SQLType(col)
|
||||
|
|
Loading…
Reference in New Issue
Block a user