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 }