From 6e3ac74b7e10ec77bc5d973ce693f0648439b888 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Thu, 28 Jan 2021 20:17:19 +0800 Subject: [PATCH] Fix preloading all associations together with nested associations, close #4016 --- callbacks/query.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/callbacks/query.go b/callbacks/query.go index fff46d57..05b572f0 100644 --- a/callbacks/query.go +++ b/callbacks/query.go @@ -172,7 +172,7 @@ func Preload(db *gorm.DB) { if name == clause.Associations { for _, rel := range db.Statement.Schema.Relationships.Relations { if rel.Schema == db.Statement.Schema { - preloadMap[rel.Name] = nil + preloadMap[rel.Name] = map[string][]interface{}{} } } } else {