fix missing error-check in AutoMigrate (#5283)

This commit is contained in:
glebarez 2022-04-22 06:19:33 +03:00 committed by GitHub
parent 88c26b62ee
commit 395606ac7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -99,7 +99,10 @@ func (m Migrator) AutoMigrate(values ...interface{}) error {
} }
} else { } else {
if err := m.RunWithValue(value, func(stmt *gorm.Statement) (errr error) { if err := m.RunWithValue(value, func(stmt *gorm.Statement) (errr error) {
columnTypes, _ := m.DB.Migrator().ColumnTypes(value) columnTypes, err := m.DB.Migrator().ColumnTypes(value)
if err != nil {
return err
}
for _, dbName := range stmt.Schema.DBNames { for _, dbName := range stmt.Schema.DBNames {
field := stmt.Schema.FieldsByDBName[dbName] field := stmt.Schema.FieldsByDBName[dbName]