Inherit SkipHooks option when preloading associations, close #3772

This commit is contained in:
Jinzhu 2020-11-20 15:11:02 +08:00
parent d66af581b4
commit e3b4e0418f
1 changed files with 1 additions and 1 deletions

View File

@ -13,7 +13,7 @@ func preload(db *gorm.DB, rels []*schema.Relationship, conds []interface{}) {
var ( var (
reflectValue = db.Statement.ReflectValue reflectValue = db.Statement.ReflectValue
rel = rels[len(rels)-1] 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 relForeignKeys []string
relForeignFields []*schema.Field relForeignFields []*schema.Field
foreignFields []*schema.Field foreignFields []*schema.Field