Skip to content

Commit

Permalink
Fix check HasColumn for sqlite, close go-gorm#865
Browse files Browse the repository at this point in the history
  • Loading branch information
jinzhu committed Mar 6, 2016
1 parent 60a859d commit 3721049
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion dialect_sqlite3.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 3721049

Please sign in to comment.