1
0
mirror of https://github.com/astaxie/beego.git synced 2025-04-03 20:35:58 +00:00

Compare commits

..

No commits in common. "master" and "v1.12.2" have entirely different histories.

2 changed files with 14 additions and 1 deletions

View File

@ -702,6 +702,13 @@ func (d *dbBase) Delete(q dbQuerier, mi *modelInfo, ind reflect.Value, tz *time.
return 0, err
}
if num > 0 {
if mi.fields.pk.auto {
if mi.fields.pk.fieldType&IsPositiveIntegerField > 0 {
ind.FieldByIndex(mi.fields.pk.fieldIndex).SetUint(0)
} else {
ind.FieldByIndex(mi.fields.pk.fieldIndex).SetInt(0)
}
}
err := d.deleteRels(q, mi, args, tz)
if err != nil {
return num, err

View File

@ -242,7 +242,13 @@ func (o *orm) Update(md interface{}, cols ...string) (int64, error) {
func (o *orm) Delete(md interface{}, cols ...string) (int64, error) {
mi, ind := o.getMiInd(md, true)
num, err := o.alias.DbBaser.Delete(o.db, mi, ind, o.alias.TZ, cols)
return num, err
if err != nil {
return num, err
}
if num > 0 {
o.setPk(mi, ind, 0)
}
return num, nil
}
// create a models to models queryer