mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 12:30:54 +00:00
orm: fix painc when pk is uint on ReadOrCreate
This commit is contained in:
parent
9f18813c2b
commit
3be6688cd1
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user