mirror of https://github.com/go-gorm/gorm.git
Fix drop table error with table options (#2447)
Fix drop table error with table options
This commit is contained in:
commit
451c3cca86
2
scope.go
2
scope.go
|
@ -1194,7 +1194,7 @@ func (scope *Scope) createTable() *Scope {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (scope *Scope) dropTable() *Scope {
|
func (scope *Scope) dropTable() *Scope {
|
||||||
scope.Raw(fmt.Sprintf("DROP TABLE %v%s", scope.QuotedTableName(), scope.getTableOptions())).Exec()
|
scope.Raw(fmt.Sprintf("DROP TABLE %v", scope.QuotedTableName())).Exec()
|
||||||
return scope
|
return scope
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,3 +78,16 @@ func TestFailedValuer(t *testing.T) {
|
||||||
t.Errorf("The error should be returned from Valuer, but get %v", err)
|
t.Errorf("The error should be returned from Valuer, but get %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDropTableWithTableOptions(t *testing.T) {
|
||||||
|
type UserWithOptions struct {
|
||||||
|
gorm.Model
|
||||||
|
}
|
||||||
|
DB.AutoMigrate(&UserWithOptions{})
|
||||||
|
|
||||||
|
DB = DB.Set("gorm:table_options", "CHARSET=utf8")
|
||||||
|
err := DB.DropTable(&UserWithOptions{}).Error
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("Table must be dropped, got error %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue