go-fiber

Update method does not update zero value

蓝咒 提交于 2021-02-11 14:13:08
问题 Original Question When using the Update method in GORM the new data does not get saved. i.e. I want to set a bool from true to false , but it stays true even after the Update method. In the description of the method there is a warning: "WARNING when update with struct, GORM will not update fields that with zero value" Since I am using a struct to update and false is the zero value of bool , this seems expected behaviour, but I don't see any reason why to do so and how to overcome this. func

Update method does not update zero value

邮差的信 提交于 2021-02-11 14:08:01
问题 Original Question When using the Update method in GORM the new data does not get saved. i.e. I want to set a bool from true to false , but it stays true even after the Update method. In the description of the method there is a warning: "WARNING when update with struct, GORM will not update fields that with zero value" Since I am using a struct to update and false is the zero value of bool , this seems expected behaviour, but I don't see any reason why to do so and how to overcome this. func