diff --git a/migrator/migrator.go b/migrator/migrator.go index 98e92c96..53fd5ac0 100644 --- a/migrator/migrator.go +++ b/migrator/migrator.go @@ -388,8 +388,9 @@ func (m Migrator) MigrateColumn(value interface{}, field *schema.Field, columnTy func (m Migrator) ColumnTypes(value interface{}) (columnTypes []*sql.ColumnType, err error) { err = m.RunWithValue(value, func(stmt *gorm.Statement) error { - rows, err := m.DB.Session(&gorm.Session{}).Raw("select * from ?", clause.Table{Name: stmt.Table}).Rows() + rows, err := m.DB.Session(&gorm.Session{}).Table(stmt.Table).Limit(1).Rows() if err == nil { + defer rows.Close() columnTypes, err = rows.ColumnTypes() } return err