Golang gorm - preload with deeply nested models
<p>I have the following contrived example:</p>

<pre><code>type Top struct {
  ID     uint `gorm:"primary_key"`
  Name   string
  Middle []*Middle
}

type Middle struct {
  ID    uint `gorm:"primary_key"`
  TopID int
  Name  string
  Low   []*Low
}

type Low struct {
  ID       uint `gorm:"primary_key"`
  MiddleID int
  Name     string
  Bottom   []*Bottom
}

type Bottom struct {
  ID    uint `gorm:"primary_key"`
  LowID int
  Name  string
}
top := Top{
  Name: "Top",
  Middle: []*Middle{
    {
      Name: "Middle",
      Low: []*Low{
        {
          Name: "Low",
          Bottom: []*Bottom{
            {
              Name: "Bottom",
            },
          },
        },
      },
    },
  },
}

if err := db.Save(&amp;top).Error; err != nil {
  log.Fatal("Got errors when saving calc", err.Error())
}

if err := db.Where("id = 1").
  Preload("Middle.Low.Bottom").
  First(&amp;top).Error; err != nil {
  log.Fatal(err)
}
</code></pre>

<p>This gives me the following output:</p>

<pre><code>(/host_home/workspace/golang/src/bitbucket.org/cloudgloballog/gormtest/main.go:81)
[2016-03-18 01:53:23]  [4.37ms]  INSERT INTO "tops" ("name") VALUES ('Top') RETURNING "tops"."id"

(/host_home/workspace/golang/src/bitbucket.org/cloudgloballog/gormtest/main.go:81)
[2016-03-18 01:53:23]  [3.49ms]  INSERT INTO "middles" ("name","top_id") VALUES ('Middle','1') RETURNING "middles"."id"

(/host_home/workspace/golang/src/bitbucket.org/cloudgloballog/gormtest/main.go:81)
[2016-03-18 01:53:23]  [1.07ms]  INSERT INTO "lows" ("middle_id","name") VALUES ('1','Low') RETURNING "lows"."id"

()
[2016-03-18 01:53:23]  [9.16ms]  INSERT INTO "bottoms" ("low_id","name") VALUES ('1','Bottom') RETURNING "bottoms"."id"

(/host_home/workspace/golang/src/bitbucket.org/cloudgloballog/gormtest/main.go:86)
[2016-03-18 01:53:23]  [1.54ms]  SELECT  * FROM "tops"   ORDER BY "tops"."id" ASC LIMIT 1

(/host_home/workspace/golang/src/bitbucket.org/cloudgloballog/gormtest/main.go:88)
[2016-03-18 01:53:23]  [2.63ms]  SELECT  * FROM "tops"  WHERE ("id" = '1') ORDER BY "tops"."id" ASC LIMIT 1

(/host_home/workspace/golang/src/bitbucket.org/cloudgloballog/gormtest/main.go:88)
[2016-03-18 01:53:23]  [1.65ms]  SELECT  * FROM "middles"  WHERE (top_id IN ('1')) ORDER BY "middles"."id" ASC

(/host_home/workspace/golang/src/bitbucket.org/cloudgloballog/gormtest/main.go:88)
[2016-03-18 01:53:23]  [4.20ms]  SELECT  * FROM "lows"  WHERE (middle_id IN ('1')) ORDER BY "lows"."id" ASC

(/host_home/workspace/golang/src/bitbucket.org/cloudgloballog/gormtest/main.go:88)
[2016-03-18 01:53:23]  can't find field Bottom in []**main.Low
</code></pre>

<p>If I were to only nest Top -> Middle -> Low and called <code>Preload("Middle.Low")</code> it works fine. The clue is probably in the double pointer reference <code>[]**main.Low</code> but I'm unable to work out how to do this properly. </p>

<p>It's possible that nested preloading is not supported to this level. Anyone know?</p>