mirror of
https://github.com/astaxie/beego.git
synced 2025-06-12 10:10:40 +00:00
orm: fix painc when pk is uint on ReadOrCreate
This commit is contained in:
@ -140,7 +140,14 @@ func (o *orm) ReadOrCreate(md interface{}, col1 string, cols ...string) (bool, i
|
||||
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
|
||||
|
Reference in New Issue
Block a user