Fix check postgres has table

This commit is contained in:
Jinzhu 2014-08-29 06:22:59 +08:00
parent 423d9496c1
commit 2d125e035c
1 changed files with 1 additions and 1 deletions

View File

@ -77,7 +77,7 @@ func (s *postgres) Quote(key string) string {
func (s *postgres) HasTable(scope *Scope, tableName string) bool { func (s *postgres) HasTable(scope *Scope, tableName string) bool {
var count int var count int
newScope := scope.New(nil) newScope := scope.New(nil)
newScope.Raw(fmt.Sprintf("SELECT count(*) FROM INFORMATION_SCHEMA.tables where table_name = %v", newScope.AddToVars(tableName))) newScope.Raw(fmt.Sprintf("SELECT count(*) FROM INFORMATION_SCHEMA.tables where table_name = %v and table_type = 'BASE TABLE'", newScope.AddToVars(tableName)))
newScope.DB().QueryRow(newScope.Sql, newScope.SqlVars...).Scan(&count) newScope.DB().QueryRow(newScope.Sql, newScope.SqlVars...).Scan(&count)
return count > 0 return count > 0
} }