Skip to content

Commit 42999e9

Browse files
committed
Fix overwrite preloading associations, close #4134
1 parent 0157099 commit 42999e9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

callbacks/query.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,9 @@ func Preload(db *gorm.DB) {
172172
if name == clause.Associations {
173173
for _, rel := range db.Statement.Schema.Relationships.Relations {
174174
if rel.Schema == db.Statement.Schema {
175-
preloadMap[rel.Name] = map[string][]interface{}{}
175+
if _, ok := preloadMap[rel.Name]; !ok {
176+
preloadMap[rel.Name] = map[string][]interface{}{}
177+
}
176178
}
177179
}
178180
} else {

0 commit comments

Comments
 (0)