GORM Playground Link

https://github.com/go-gorm/playground/pull/576

Description

In our application we'd like to have a similar structure to this:

type Org struct {
    ID              uuid.UUID `gorm:"primaryKey"`
    Name            string
    PostalAddress   Address `gorm:"embedded;embeddedPrefix:postal_address_"`
    VisitingAddress Address `gorm:"embedded;embeddedPrefix:visiting_address_"`
}
type Address struct {
    City      string
    Street    string
    CountryID uuid.UUID
    Country   Country
}

type Country struct {
    ID   uuid.UUID `gorm:"primaryKey"`
    Name string
}

Notably the Org contains two gorm-embedded Structs of the same type with different embeddedPrefixes. Everything worked fine with this, until we decided to add a relation to the embedded field - Country. It looks like it's basically impossible to Preload/Join the country when Finding the orgs.

We tried things like:

db.Preload(clause.Associations).First(&orgWithCountries)
db.Preload("Country").First(&orgWithCountries)
db.Preload("VisitingAddress.Country").First(&orgWithCountries)

but none of them work, (the first two only resolve one of the countries, and the third one doesn't work at all)

Comment From: black-06

I would like to pick it up