From 37210495bf8f45b01cbdeb8379f49fe427ae8521 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Sun, 6 Mar 2016 09:34:09 +0800 Subject: [PATCH] Fix check HasColumn for sqlite, close #865 --- dialect_sqlite3.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dialect_sqlite3.go b/dialect_sqlite3.go index 56c847b5..5c262aaf 100644 --- a/dialect_sqlite3.go +++ b/dialect_sqlite3.go @@ -83,7 +83,7 @@ func (s sqlite3) HasTable(tableName string) bool { func (s sqlite3) HasColumn(tableName string, columnName string) bool { var count int - s.db.QueryRow(fmt.Sprintf("SELECT count(*) FROM sqlite_master WHERE tbl_name = ? AND (sql LIKE '%%(\"%v\" %%' OR sql LIKE '%%,\"%v\" %%' OR sql LIKE '%%, \"%v\" %%' OR sql LIKE '%%( %v %%' OR sql LIKE '%%, %v %%' OR sql LIKE '%%,%v %%');\n", columnName, columnName, columnName, columnName, columnName, columnName), tableName).Scan(&count) + s.db.QueryRow(fmt.Sprintf("SELECT count(*) FROM sqlite_master WHERE tbl_name = ? AND (sql LIKE '%%\"%v\" %%' OR sql LIKE '%%%v %%');\n", columnName, columnName), tableName).Scan(&count) return count > 0 }