mirror of https://github.com/go-gorm/gorm.git
Fix check HasColumn for sqlite3
This commit is contained in:
parent
2d3bcf5297
commit
7bad7e7427
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue