From 37cb292530624a157e05e59ad8f037193639b5b6 Mon Sep 17 00:00:00 2001 From: Aaron Liu <912394456@qq.com> Date: Sun, 12 Feb 2023 20:02:35 +0800 Subject: [PATCH] fix(db): SQLite3 dialects return empty rows in `HasColumn` method --- models/dialects/dialect_sqlite.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/dialects/dialect_sqlite.go b/models/dialects/dialect_sqlite.go index 6fa7c66fdd..83894d070b 100644 --- a/models/dialects/dialect_sqlite.go +++ b/models/dialects/dialect_sqlite.go @@ -265,7 +265,7 @@ func (s sqlite) HasTable(tableName string) bool { func (s sqlite) 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 %%');\n", 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 %%');", columnName, columnName), tableName).Scan(&count) return count > 0 }