fix: Allowing the settings be passed through

This commit is contained in:
Lewis Theobald 2021-01-14 15:46:44 +00:00 committed by GitHub
parent 79628be2c2
commit 26f701ab57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -316,6 +316,12 @@ func (db *DB) getInstance() *DB {
Clauses: map[string]clause.Clause{},
Vars: make([]interface{}, 0, 8),
}
// Carry over the settings previously defined so that you can access them in the preload callbacks
db.Statement.Settings.Range(func(k, v interface{}) bool {
tx.Statement.Settings.Store(k, v)
return true
})
} else {
// with clone statement
tx.Statement = db.Statement.clone()