diff options
Diffstat (limited to 'vendor/github.com/uptrace/bun/schema/table.go')
-rw-r--r-- | vendor/github.com/uptrace/bun/schema/table.go | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/vendor/github.com/uptrace/bun/schema/table.go b/vendor/github.com/uptrace/bun/schema/table.go index 8bed5ed38..213f821ab 100644 --- a/vendor/github.com/uptrace/bun/schema/table.go +++ b/vendor/github.com/uptrace/bun/schema/table.go @@ -181,17 +181,17 @@ func (t *Table) initFields() { t.FieldMap = make(map[string]*Field, t.Type.NumField()) t.addFields(t.Type, nil) - if len(t.PKs) > 0 { - return - } - for _, name := range []string{"id", "uuid", "pk_" + t.ModelName} { - if field, ok := t.FieldMap[name]; ok { - field.markAsPK() - t.PKs = []*Field{field} - t.DataFields = removeField(t.DataFields, field) - break + if len(t.PKs) == 0 { + for _, name := range []string{"id", "uuid", "pk_" + t.ModelName} { + if field, ok := t.FieldMap[name]; ok { + field.markAsPK() + t.PKs = []*Field{field} + t.DataFields = removeField(t.DataFields, field) + break + } } } + if len(t.PKs) == 1 { pk := t.PKs[0] if pk.SQLDefault != "" { |