diff --git a/main.go b/main.go index ff707f3f..f2eeb5d6 100644 --- a/main.go +++ b/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 diff --git a/scope.go b/scope.go index 2fa4acdb..a11d4ec4 100644 --- a/scope.go +++ b/scope.go @@ -267,10 +267,6 @@ type dbTabler interface { // TableName get table name func (scope *Scope) TableName() string { - if strTableName, ok := scope.Value.(string); ok { - return strTableName - } - if scope.Search != nil && len(scope.Search.tableName) > 0 { return scope.Search.tableName }