Your Question

In composited model, like below:

type Thing1 struct {
    Id1  uint   `gorm:"primarykey"`
    Name string `gorm:"size:20"`
    One  int
}

type Thing2 struct {
    Id2  uint   `gorm:"primarykey"`
    Name string `gorm:"size:20"`
    Two  int
}

type Thing3 struct {
    Id3   uint   `gorm:"primarykey"`
    Name  string `gorm:"size:20"`
    Three int
}

type Composite struct {
    Thing1
    Thing2 Thing2 `gorm:"foreignKey:Id2;references:Id1"`
    Thing3 Thing3 `gorm:"foreignKey:Id3;references:Id1"`
}

The document you expected this should be explained

not found in docs or examples

How to make custom join worked?

var result Composite
DB.Table("thing1").
  // worked
  // Joins("Thing2").
  // not worked
  Joins("LEFT JOIN thing2 Thing2 ON thing1.id1=thing2.id2 AND thing2.two=2").
  Joins("Thing3").
  Find(&result)

Also PR in here

Thanks

Comment From: black-06

var result Composite
DB.Table("thing1").
    Joins("Thing2", DB.Model(&Thing2{}).Where(&Thing2{Two: 2})).
    Joins("Thing3").
    Find(&result)

docs is Join with conditions in https://gorm.io/docs/preload.html#Joins-Preloading

Comment From: pedia

This worked, Thanks a lot @black-06 And great docs.