orm: fix miss pk when pk is negative

This commit is contained in:
miraclesu
2016-03-17 21:34:49 +08:00
parent c8bbfb75f0
commit a3d4218d9d
5 changed files with 12 additions and 12 deletions

View File

@@ -159,7 +159,7 @@ func (o *orm) Insert(md interface{}) (int64, error) {
// set auto pk field
func (o *orm) setPk(mi *modelInfo, ind reflect.Value, id int64) {
if mi.fields.pk.auto {
if mi.fields.pk.fieldType&IsPostiveIntegerField > 0 {
if mi.fields.pk.fieldType&IsPositiveIntegerField > 0 {
ind.FieldByIndex(mi.fields.pk.fieldIndex).SetUint(uint64(id))
} else {
ind.FieldByIndex(mi.fields.pk.fieldIndex).SetInt(id)