From ca4fcb94c0316294a9518590b548779ca36147c0 Mon Sep 17 00:00:00 2001 From: a631807682 <631807682@qq.com> Date: Thu, 22 Sep 2022 12:06:54 +0800 Subject: [PATCH] perf: check type --- migrator/migrator.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/migrator/migrator.go b/migrator/migrator.go index 0cc78ca7..29c0c00c 100644 --- a/migrator/migrator.go +++ b/migrator/migrator.go @@ -411,12 +411,18 @@ func (m Migrator) MigrateColumn(value interface{}, field *schema.Field, columnTy if !field.PrimaryKey { // check type var isSameType bool - aliases := m.DB.Migrator().GetTypeAliases(realDataType) - aliases = append(aliases, realDataType) - for _, alias := range aliases { - if strings.HasPrefix(fullDataType, alias) { - isSameType = true - break + if strings.HasPrefix(fullDataType, realDataType) { + isSameType = true + } + + // check type aliases + if !isSameType { + aliases := m.DB.Migrator().GetTypeAliases(realDataType) + for _, alias := range aliases { + if strings.HasPrefix(fullDataType, alias) { + isSameType = true + break + } } }