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,14 +411,20 @@ func (m Migrator) MigrateColumn(value interface{}, field *schema.Field, columnTy
if !field.PrimaryKey {
// check type
var isSameType bool
if strings.HasPrefix(fullDataType, realDataType) {
isSameType = true
}
// check type aliases
if !isSameType {
aliases := m.DB.Migrator().GetTypeAliases(realDataType)
aliases = append(aliases, realDataType)
for _, alias := range aliases {
if strings.HasPrefix(fullDataType, alias) {
isSameType = true
break
}
}
}
if !isSameType {
alterColumn = true