Open ys3d opened 1 year ago
Update: Directly fetching an element of type JobData works perfectly fine using both relations
up I get the same error using such syntax when Data is null
Model(&job).
WherePK().
Relation("Data.Config").
Relation("Data.Points").
Scan(context.Background())
I'm getting the same error. My model is:
type User struct {
bun.BaseModel `bun:"table:user,alias:u"`
ID int64
Name string
Password string
SuperUser *SuperUser `bun:"su,rel:has-one,join:id=user_id"`
ClientUser *ClientUser `bun:"cu,rel:has-one,join:id=user_id"`
}
type SuperUser struct {
bun.BaseModel `bun:"table:super_user,alias:su"`
ID int64
Email string
UserID int64
User *User `bun:"rel:belongs-to,join:user_id=id"`
}
type ClientUser struct {
bun.BaseModel `bun:"table:client_user,alias:cu"`
ID int64
Email string
UserID int64
User *User `bun:"rel:belongs-to,join:user_id=id"`
}
type Order struct {
bun.BaseModel `bun:"table:order,alias:o"`
ID int64
OwnerID int64
Owner *User `bun:"rel:belongs-to,join:owner_id=id"`
}
And I try the request:
Model(&order).
Relation("Owner").
Scan(context.Background())
It fails when I've values in both user tables (ClientUser and SuperUser)
This issue is duplicating => https://github.com/uptrace/bun/issues/872
I defined the following structs:
I tried to pull an element of JobData with:
In case I only try to resolve the relation "Config" everything works fine. The relation "Points" causes the following error. The error is caused with and without additionally requesting the "Config" relation:
Does anybody have an idea what is causing this behaviour? Is that an bug or is it an mistake on my side?