diff --git a/callbacks/associations.go b/callbacks/associations.go index 0fa47868..e6669600 100644 --- a/callbacks/associations.go +++ b/callbacks/associations.go @@ -359,7 +359,7 @@ func saveAssociations(db *gorm.DB, rel *schema.Relationship, values interface{}, } } - tx := db.Session(&gorm.Session{NewDB: true}).Clauses(onConflict) + tx := db.Session(&gorm.Session{NewDB: true}).Clauses(onConflict).Session(&gorm.Session{SkipHooks: db.Statement.SkipHooks}) if len(selects) > 0 { tx = tx.Select(selects) diff --git a/callbacks/preload.go b/callbacks/preload.go index c2304af8..682427c9 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, SkipHooks: db.Statement.SkipHooks}) + tx = db.Session(&gorm.Session{NewDB: true}).Model(nil).Session(&gorm.Session{SkipHooks: db.Statement.SkipHooks}) relForeignKeys []string relForeignFields []*schema.Field foreignFields []*schema.Field