Fix check HasColumn for sqlite3

This commit is contained in:
Jinzhu 2014-07-25 18:14:44 +08:00
parent 2d3bcf5297
commit 7bad7e7427
1 changed files with 1 additions and 1 deletions

View File

@ -68,6 +68,6 @@ func (s *sqlite3) HasTable(scope *Scope, tableName string) bool {
func (s *sqlite3) HasColumn(scope *Scope, tableName string, columnName string) bool { func (s *sqlite3) HasColumn(scope *Scope, tableName string, columnName string) bool {
var count int 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 return count > 0
} }