go-gorm / playground

GORM Playground (Please Create PR for this project to report issues)
MIT License
88 stars 666 forks source link

print wrong sql when use where func #702

Closed wangzeping722 closed 4 months ago

wangzeping722 commented 4 months ago

Explain your user case and expected results

I define that the underlying data type is the structure of int, UserStatus, when I use the where statement to query like DB.Where("status = ?", Normal).Find(&users), it printUserStatus as string rather than number : test-img

and, when I use the int to query, it works normally. DB.Where("status = ?", 1).Find(&users)

        // SELECT * FROM `users` WHERE status = '1' AND `users`.`deleted_at` IS NULL
    DB.Where("status = ?", Normal).Find(&users)

       // SELECT * FROM `users` WHERE status = 1 AND `users`.`deleted_at` IS NULL
    DB.Where("status = ?", 1).Find(&users)