Fix Set/Get settings when saving associations, close #3908

This commit is contained in:
Jinzhu 2021-01-05 21:12:31 +08:00
parent 53b3ebdd1d
commit 6d260a86bd
1 changed files with 5 additions and 0 deletions

View File

@ -363,6 +363,11 @@ func saveAssociations(db *gorm.DB, rel *schema.Relationship, values interface{},
DisableNestedTransaction: true, DisableNestedTransaction: true,
}) })
db.Statement.Settings.Range(func(k, v interface{}) bool {
tx.Statement.Settings.Store(k, v)
return true
})
if len(selects) > 0 { if len(selects) > 0 {
tx = tx.Select(selects) tx = tx.Select(selects)
} }