1
0
mirror of https://github.com/astaxie/beego.git synced 2024-12-23 02:40:50 +00:00

Merge pull request #3530 from GeorgeXc/develop

[orm] add ignore auto_now_add field when update
This commit is contained in:
astaxie 2019-03-27 00:14:07 +08:00 committed by GitHub
commit 610f27d684
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -621,6 +621,20 @@ 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 {
setNames = append(setNames[0:index], setNames[index+1:]...)
setValues = append(setValues[0:index], setValues[index+1:]...)
}
setValues = append(setValues, pkValue)
Q := d.ins.TableQuote()