SELECT * FROM admin ORDER BY admin.id LIMIT 1
gorm解析的是这样,有配置去掉 ` 符号吗
我想要 SELECT * FROM admin ORDER BY admin.id LIMIT 1
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: philhuan
type MyDiatector struct {
gorm.Dialector
}
func (d MyDiatector) QuoteTo(writer clause.Writer, str string) {
writer.WriteString(str)
}
func NotQuete(o gorm.Dialector) gorm.Dialector{
return &MyDiatector{Dialector: o}
}
func Test_Quote(t *testing.T) {
dbDSN := "gorm:gorm@tcp(localhost:9910)/gorm?charset=utf8&parseTime=True&loc=Local"
db, err := gorm.Open(NotQuete(mysql.Open(dbDSN)), &gorm.Config{})
assert.NoError(t, err)
db.Logger = db.Logger.LogMode(logger.Info)
var u User
err = db.Model(User{}).Where("id=?", 1).First(&u).Error
assert.NoError(t, err)
t.Log(u)
}
=== RUN Test_Quote
2023/05/15 23:12:57 /Users/philhuan/code/go/playground/main_test.go:93
[3.565ms] [rows:1] SELECT * FROM users WHERE id=1 AND users.deleted_at IS NULL ORDER BY users.id LIMIT 1
main_test.go:96: {{1 2023-05-15 00:23:36.84 +0800 CST 2023-05-15 00:23:36.84 +0800 CST {0001-01-01 00:00:00 +0000 UTC false}} jinzhu 0 <nil> {{0 0001-01-01 00:00:00 +0000 UTC 0001-01-01 00:00:00 +0000 UTC {0001-01-01 00:00:00 +0000 UTC false}} {0 false} } [] [] <nil> {0 } <nil> <nil> [] [] [] false}
--- PASS: Test_Quote (0.01s)
PASS
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 ✨