Fix overwrite preloading associations, close #4134

This commit is contained in:
Jinzhu 2021-03-04 18:28:32 +08:00
parent 0157099576
commit 42999e9809
1 changed files with 3 additions and 1 deletions

View File

@ -172,7 +172,9 @@ 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] = map[string][]interface{}{}
if _, ok := preloadMap[rel.Name]; !ok {
preloadMap[rel.Name] = map[string][]interface{}{}
}
}
}
} else {