Merge branch 'jsternberg-migrator-release-conn'

This commit is contained in:
Jinzhu 2020-09-09 10:56:07 +08:00
commit 0b6ef3cb87
1 changed files with 2 additions and 1 deletions

View File

@ -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