From 98c4b78e4dcceea93eaaabd051f8c021e645e017 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Fri, 28 Jan 2022 19:26:10 +0800 Subject: [PATCH] Add Session Initialized option --- gorm.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gorm.go b/gorm.go index fc70f684..a982bee4 100644 --- a/gorm.go +++ b/gorm.go @@ -96,6 +96,7 @@ type Session struct { DryRun bool PrepareStmt bool NewDB bool + Initialized bool SkipHooks bool SkipDefaultTransaction bool DisableNestedTransaction bool @@ -282,6 +283,10 @@ func (db *DB) Session(config *Session) *DB { tx.Config.NowFunc = config.NowFunc } + if config.Initialized { + tx = tx.getInstance() + } + return tx }