From e3b4e0418f2c9c4670bf21f6d9d63caa5a0903ce Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Fri, 20 Nov 2020 15:11:02 +0800 Subject: [PATCH] Inherit SkipHooks option when preloading associations, close #3772 --- callbacks/preload.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/callbacks/preload.go b/callbacks/preload.go index e1dfdace..c2304af8 100644 --- a/callbacks/preload.go +++ b/callbacks/preload.go @@ -13,7 +13,7 @@ func preload(db *gorm.DB, rels []*schema.Relationship, conds []interface{}) { var ( reflectValue = db.Statement.ReflectValue rel = rels[len(rels)-1] - tx = db.Session(&gorm.Session{NewDB: true}) + tx = db.Session(&gorm.Session{NewDB: true, SkipHooks: db.Statement.SkipHooks}) relForeignKeys []string relForeignFields []*schema.Field foreignFields []*schema.Field