From 59fa07953cf43385587677f106bb5e522621dca1 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Fri, 15 Jan 2021 17:15:59 +0800 Subject: [PATCH] Preload with settings, close #3945 --- callbacks/preload.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/callbacks/preload.go b/callbacks/preload.go index 5c56d851..3614346f 100644 --- a/callbacks/preload.go +++ b/callbacks/preload.go @@ -22,6 +22,11 @@ func preload(db *gorm.DB, rels []*schema.Relationship, conds []interface{}) { inlineConds []interface{} ) + db.Statement.Settings.Range(func(k, v interface{}) bool { + tx.Statement.Settings.Store(k, v) + return true + }) + if len(rels) > 1 { reflectValue = schema.GetRelationsValues(reflectValue, rels[:len(rels)-1]) }