Quantcast
Channel: User Norbert - Stack Overflow
Viewing all articles
Browse latest Browse all 42

Answer by Norbert for How to fix unsupported relations for schema error with gorm.Preload

$
0
0

You are not using the standard gorm.Model for the keys (from the docs):

type Model struct {  ID        uint           `gorm:"primaryKey"`  CreatedAt time.Time  UpdatedAt time.Time  DeletedAt gorm.DeletedAt `gorm:"index"`}

Gorm uses this to identify joins.

Changing your keys with the gorm:"primaryKey" indicator should fix the issue.

Or alternative: use gorm.Model:

type Ticker struct {    gorm.Model    ShopID              uuid.UUID  `json:"shopID"`    Archived            bool       `json:"archived"`    Services            []string   `json:"services"`    Price               int        `json:"price"`    Location            int        `json:"location"`    Checkedout          bool       `json:"checkedout"`    TechnicianID        uuid.UUID  `json:"technicianId"`    Technician          Technician `json:"technician"`    TechnicianPartnerID *uuid.UUID `json:"technicianPartnerId"`    LastUpdatedBy       uuid.UUID  `json:"lastupdatedBy"`}type Technician struct {    gorm.Model    ShopID    uuid.UUID `json:"shopID"`    Name      string    `json:"name"`    Active    bool      `json:"active"`}

Viewing all articles
Browse latest Browse all 42

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>