1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-26 10:01:28 +00:00

orm: fix painc when pk is uint on ReadOrCreate

This commit is contained in:
miraclesu 2016-03-23 21:18:54 +08:00
parent 9f18813c2b
commit 3be6688cd1

View File

@ -140,7 +140,14 @@ func (o *orm) ReadOrCreate(md interface{}, col1 string, cols ...string) (bool, i
return (err == nil), id, err return (err == nil), id, err
} }
return false, ind.FieldByIndex(mi.fields.pk.fieldIndex).Int(), err id, vid := int64(0), ind.FieldByIndex(mi.fields.pk.fieldIndex)
if mi.fields.pk.fieldType&IsPostiveIntegerField > 0 {
id = int64(vid.Uint())
} else {
id = vid.Int()
}
return false, id, err
} }
// insert model data to database // insert model data to database