From 428bfe4f46c83ae6e8c23f87c2b1830f6bae8b30 Mon Sep 17 00:00:00 2001 From: Ryan Liu Date: Mon, 16 May 2022 15:17:16 +0800 Subject: [PATCH] fix the error in mysql: unknown colType UNSIGNED FLOAT --- dialects/mysql.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/dialects/mysql.go b/dialects/mysql.go index 56ba66c7..ba5c06d8 100644 --- a/dialects/mysql.go +++ b/dialects/mysql.go @@ -492,10 +492,16 @@ 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" {