Fix setPK function for table without primary key (#5276)

This commit is contained in:
mlgd 2023-07-14 09:00:02 +02:00 committed by GitHub
parent 24b41552c5
commit bd01665cb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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