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
1 changed files with 8 additions and 1 deletions

View File

@ -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