gorm
gorm copied to clipboard
logger format error, logger can't parse "%"
logger format error, logger can't parse "%"
When i run this code,
tx = tx.Where("username like ?", "%"+dtoUser.Username+"%")
I got this log
[0.613ms] [rows:1] SELECT * FROM `users` WHERE username like '%!a(MISSING)dmin%!'(MISSING)
The document you expected this should be explained
Expected answer
I want the log like this
SELECT * FROM `users` WHERE username like %admin%
The logger make %a and %' as format character.
func TestGORM(t *testing.T) {
user := User{Name: "jinzhu"}
DB.Create(&user)
var users []User
DB.Where("name LIKE ?", "%"+user.Name+"%").Find(&users)
}
It's work in last version, maybe you used format
like fmt.Printf
We had the same problem! Query works correctly but it prints the !(MISSING) on the logs and it creates confusion while debugging the code.