mirror of https://github.com/go-gorm/gorm.git
Fix overwrite preloading associations, close #4134
This commit is contained in:
parent
0157099576
commit
42999e9809
|
@ -172,9 +172,11 @@ func Preload(db *gorm.DB) {
|
||||||
if name == clause.Associations {
|
if name == clause.Associations {
|
||||||
for _, rel := range db.Statement.Schema.Relationships.Relations {
|
for _, rel := range db.Statement.Schema.Relationships.Relations {
|
||||||
if rel.Schema == db.Statement.Schema {
|
if rel.Schema == db.Statement.Schema {
|
||||||
|
if _, ok := preloadMap[rel.Name]; !ok {
|
||||||
preloadMap[rel.Name] = map[string][]interface{}{}
|
preloadMap[rel.Name] = map[string][]interface{}{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
preloadFields := strings.Split(name, ".")
|
preloadFields := strings.Split(name, ".")
|
||||||
if _, ok := preloadMap[preloadFields[0]]; !ok {
|
if _, ok := preloadMap[preloadFields[0]]; !ok {
|
||||||
|
|
Loading…
Reference in New Issue