gorm icon indicating copy to clipboard operation
gorm copied to clipboard

logger format error, logger can't parse "%"

Open notnotype opened this issue 2 years ago • 2 comments

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.

notnotype avatar Apr 15 '22 09:04 notnotype

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

a631807682 avatar Apr 16 '22 06:04 a631807682

We had the same problem! Query works correctly but it prints the !(MISSING) on the logs and it creates confusion while debugging the code.

sergi-unimedia avatar Oct 26 '22 14:10 sergi-unimedia