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 :
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)
Explain your user case and expected results
I define that the underlying data type is the structure of int,![test-img](https://github.com/go-gorm/playground/assets/26428456/dc9cd297-e0a7-4aa1-a2b5-fb559296cc10)
UserStatus
, when I use the where statement to query likeDB.Where("status = ?", Normal).Find(&users)
, it printUserStatus
asstring
rather thannumber
:and, when I use the
int
to query, it works normally.DB.Where("status = ?", 1).Find(&users)