From 26f701ab5795bccc20db1192e8cb14c230ad91da Mon Sep 17 00:00:00 2001 From: Lewis Theobald Date: Thu, 14 Jan 2021 15:46:44 +0000 Subject: [PATCH] fix: Allowing the settings be passed through --- gorm.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gorm.go b/gorm.go index 88885407..f37374cb 100644 --- a/gorm.go +++ b/gorm.go @@ -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()