I'm trying to update an existing record in PostgreSQL database. I have a column which accepts integers. I have tried doing the update using db query written in gorm. All the integers are getting updated except 0
(zero).
Can anyone help me fix this issue?
type RoleTypes struct {
ID int `gorm:"primary_key,AUTO_INCREMENT"`
RoleName string
IsEnable int
}
Below is the db query:
func UpdateRoles(db *gorm.DB, r *models.RoleTypes) (err error) {
Logr.Debug("Inside UpdateRoles method")
if err = db.Debug().Model(&r).Where("ID=?", r.ID).Update(&r).Error; err != nil {
Logr.Error("error occured!!", zap.Any("Error", err))
return err
}
return nil
}
I'm trying to Update the IsEnable
to 0
(Zero).