fix the error in mysql: unknown colType UNSIGNED FLOAT

This commit is contained in:
Ryan Liu 2022-05-16 15:17:16 +08:00
parent 26d291bbc3
commit 428bfe4f46
1 changed files with 9 additions and 3 deletions

View File

@ -492,11 +492,17 @@ func (db *mysql) GetColumns(queryer core.Queryer, ctx context.Context, tableName
}
col.Length = len1
col.Length2 = len2
if _, ok := schemas.SqlTypes[colType]; ok {
col.SQLType = schemas.SQLType{Name: colType, DefaultLength: len1, DefaultLength2: len2}
} else {
if _, ok := schemas.SqlTypes[colType]; !ok {
if !strings.HasPrefix(colType, "UNSIGNED ") {
return nil, nil, fmt.Errorf("unknown colType %v", colType)
}
colType = colType[len("UNSIGNED "):]
}
if _, ok := schemas.SqlTypes[colType]; !ok {
return nil, nil, fmt.Errorf("unknown colType %v", colType)
} else {
col.SQLType = schemas.SQLType{Name: colType, DefaultLength: len1, DefaultLength2: len2}
}
if colKey == "PRI" {
col.IsPrimaryKey = true