From bd01665cb1f2fa4b723f64a05df48e408a0b35aa Mon Sep 17 00:00:00 2001 From: mlgd Date: Fri, 14 Jul 2023 09:00:02 +0200 Subject: [PATCH] Fix setPK function for table without primary key (#5276) --- client/orm/orm.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/orm/orm.go b/client/orm/orm.go index bd84e6df..b7048409 100644 --- a/client/orm/orm.go +++ b/client/orm/orm.go @@ -210,7 +210,7 @@ func (o *ormBase) InsertWithCtx(ctx context.Context, md interface{}) (int64, err // set auto pk field func (*ormBase) setPk(mi *models.ModelInfo, ind reflect.Value, id int64) { - if mi.Fields.Pk.Auto { + if mi.Fields.Pk != nil && mi.Fields.Pk.Auto { if mi.Fields.Pk.FieldType&IsPositiveIntegerField > 0 { ind.FieldByIndex(mi.Fields.Pk.FieldIndex).SetUint(uint64(id)) } else {