mirror of https://github.com/go-gorm/gorm.git
allow SkipHooks when preload & save associations
This commit is contained in:
parent
dec8748512
commit
6186a4daa7
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue