mirror of https://github.com/go-gorm/gorm.git
Check argument is string or not in HasTable
This commit is contained in:
parent
3c9d2b1af6
commit
77928d8373
13
main.go
13
main.go
|
@ -406,8 +406,17 @@ func (s *DB) DropTableIfExists(values ...interface{}) *DB {
|
|||
}
|
||||
|
||||
func (s *DB) HasTable(value interface{}) bool {
|
||||
scope := s.clone().NewScope(value)
|
||||
tableName := scope.TableName()
|
||||
var (
|
||||
scope = s.clone().NewScope(value)
|
||||
tableName string
|
||||
)
|
||||
|
||||
if name, ok := value.(string); ok {
|
||||
tableName = name
|
||||
} else {
|
||||
tableName = scope.TableName()
|
||||
}
|
||||
|
||||
has := scope.Dialect().HasTable(scope, tableName)
|
||||
s.AddError(scope.db.Error)
|
||||
return has
|
||||
|
|
Loading…
Reference in New Issue