perf: check type

This commit is contained in:
a631807682 2022-09-22 12:06:54 +08:00
parent 311b852cfd
commit ca4fcb94c0
No known key found for this signature in database
GPG Key ID: 137D1D75522168AB

View File

@ -411,12 +411,18 @@ func (m Migrator) MigrateColumn(value interface{}, field *schema.Field, columnTy
if !field.PrimaryKey { if !field.PrimaryKey {
// check type // check type
var isSameType bool var isSameType bool
aliases := m.DB.Migrator().GetTypeAliases(realDataType) if strings.HasPrefix(fullDataType, realDataType) {
aliases = append(aliases, realDataType) isSameType = true
for _, alias := range aliases { }
if strings.HasPrefix(fullDataType, alias) {
isSameType = true // check type aliases
break if !isSameType {
aliases := m.DB.Migrator().GetTypeAliases(realDataType)
for _, alias := range aliases {
if strings.HasPrefix(fullDataType, alias) {
isSameType = true
break
}
} }
} }