发布于 2021-07-04 13:30:18
你试过用标签吗?
我的想法是将DEFAULT标记和值设置为null并对其进行更新。就像这样:
type Table struct {
// other fields
Number `sql:"DEFAULT:0"`
}
modelTable := Table{}
// jobs and insert
// get model and prepare then update Number
modelTable.Number = null.IntFromPtr(nil)
modelTable.Update()要创建空值,请使用空包。
如果这不起作用,那么您应该使用Raw sql。
https://stackoverflow.com/questions/68243796
复制相似问题