1
0
mirror of https://github.com/astaxie/beego.git synced 2025-07-13 13:41:02 +00:00

4 Commits

Author SHA1 Message Date
56d89cc55c Merge pull request #8 from flycash/fix4734-1x
do not reset id to 0
2021-08-20 19:54:42 +08:00
e048377594 do not reset id to 0 2021-08-20 19:53:51 +08:00
34334a52be Merge pull request #7 from flycash/fix4734-1x
Fix 4734: we don't need to reset the id to 0
2021-08-19 21:52:16 +08:00
7cdf96d21a Fix 4734: we don't need to reset the id to 0 2021-08-19 21:49:37 +08:00
2 changed files with 1 additions and 14 deletions

View File

@ -702,13 +702,6 @@ func (d *dbBase) Delete(q dbQuerier, mi *modelInfo, ind reflect.Value, tz *time.
return 0, err return 0, err
} }
if num > 0 { 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) err := d.deleteRels(q, mi, args, tz)
if err != nil { if err != nil {
return num, err return num, err

View File

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