From 2d125e035ce23130a37b4ff522868725e360628b Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Fri, 29 Aug 2014 06:22:59 +0800 Subject: [PATCH] Fix check postgres has table --- postgres.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres.go b/postgres.go index c137f182..aab5757a 100644 --- a/postgres.go +++ b/postgres.go @@ -77,7 +77,7 @@ func (s *postgres) Quote(key string) string { func (s *postgres) HasTable(scope *Scope, tableName string) bool { var count int 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) return count > 0 }