Fix fail on sqlserver, #3433

This commit is contained in:
Jinzhu 2020-09-09 10:53:13 +08:00
parent e7188c04ca
commit 567597f000
1 changed files with 2 additions and 2 deletions

View File

@ -388,10 +388,10 @@ 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 ? limit 1", 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()
_ = rows.Close()
}
return err
})