SQLite command PRAGMA table_ Is info ([table name]) not supported by Gorm?
The document you expected this should be explained
os windows11 go version 1.18 gorm.io/gorm version 1.23.3 gorm.io/driver/sqlite version 1.3.1
func TestEx(t *testing.T) {
//var ss []tabb
db := repository.GetDB()
var tabs []tabb
sql := "PRAGMA table_info([notices])"
db.Debug().Exec(sql).Scan(&tabs)
println(tabs)
db2, _ := db.DB()
rows, _ := db2.Query(sql)
for rows.Next() {
var alb tabb
if err := rows.Scan(&alb.Cid, &alb.Name, &alb.Type, &alb.Notnull, &alb.DfltValue, &alb.Pk); err == nil {
tabs = append(tabs, alb)
}
}
fmt.Println(11)
}
debug info:
=== RUN TestEx
2022/03/30 11:44:34 D:/Homework/CodingProjects/web-server/test/DB_test.go:88 SLOW SQL >= 200ms
[128228.147ms] [rows:0] PRAGMA table_info([notices])
2022/03/30 11:44:36 D:/Homework/CodingProjects/web-server/test/DB_test.go:88 no such table:
[1225.147ms] [rows:-] SELECT * FROM ``
[0/0]0x0
11
--- PASS: TestEx (176.62s)
PASS
I want
Is there a feasible solution to my problem
Comment From: github-actions[bot]
The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking ✨
Comment From: feiquan666
应该使用
db.Raw("sql").Scan(&res)