Skip to content

Commit

Permalink
Fix check HasColumn for sqlite3
Browse files Browse the repository at this point in the history
  • Loading branch information
jinzhu committed Jul 26, 2014
1 parent 7bad7e7 commit 6a00344
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion sqlite3.go
Original file line number Diff line number Diff line change
Expand Up @@ -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\" %%' OR sql LIKE '%%( %v %%' OR sql LIKE '%%, %v %%');\n", tableName, columnName, columnName, 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
}

0 comments on commit 6a00344

Please sign in to comment.