1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 05:40:54 +00:00

add ignore auto_now_add field when update

This commit is contained in:
BaoyangChai 2019-02-12 18:05:29 +08:00
parent 3224369ac9
commit ba17bdd366

View File

@ -621,6 +621,25 @@ func (d *dbBase) Update(q dbQuerier, mi *modelInfo, ind reflect.Value, tz *time.
return 0, err
}
var find bool
var index int
for i, col := range setNames {
if mi.fields.GetByColumn(col).autoNowAdd {
index = i
find = true
}
}
if find {
newSetNames := make([]string, 0, 0)
newSetNames = append(setNames[0:index], setNames[index+1:]...)
setNames = newSetNames
newSetValues := make([]interface{}, 0, 0)
newSetValues = append(setValues[0:index], setValues[index+1:]...)
setValues = newSetValues
}
setValues = append(setValues, pkValue)
Q := d.ins.TableQuote()