From 7bad7e7427d60bbe1699594a9089661295b21a56 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Fri, 25 Jul 2014 18:14:44 +0800 Subject: [PATCH] Fix check HasColumn for sqlite3 --- sqlite3.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqlite3.go b/sqlite3.go index b454930b..0aab7d34 100644 --- a/sqlite3.go +++ b/sqlite3.go @@ -68,6 +68,6 @@ func (s *sqlite3) HasTable(scope *Scope, tableName string) bool { func (s *sqlite3) HasColumn(scope *Scope, tableName string, columnName string) bool { var count int - scope.DB().QueryRow(fmt.Sprintf("SELECT count(*) FROM sqlite_master WHERE tbl_name = '%v' AND (sql LIKE '%%(\"%v\" %%' OR sql LIKE '%%,\"%v\" %%');\n", tableName, columnName, columnName)).Scan(&count) + scope.DB().QueryRow(fmt.Sprintf("SELECT count(*) FROM sqlite_master WHERE tbl_name = '%v' AND (sql LIKE '%%(\"%v\" %%' OR sql LIKE '%%,\"%v\" %%' OR sql LIKE '%%( %v %%' OR sql LIKE '%%, %v %%');\n", tableName, columnName, columnName, columnName, columnName)).Scan(&count) return count > 0 }