Add Session Initialized option

This commit is contained in:
Jinzhu 2022-01-28 19:26:10 +08:00
parent cec0d32aec
commit 98c4b78e4d
1 changed files with 5 additions and 0 deletions

View File

@ -96,6 +96,7 @@ type Session struct {
DryRun bool DryRun bool
PrepareStmt bool PrepareStmt bool
NewDB bool NewDB bool
Initialized bool
SkipHooks bool SkipHooks bool
SkipDefaultTransaction bool SkipDefaultTransaction bool
DisableNestedTransaction bool DisableNestedTransaction bool
@ -282,6 +283,10 @@ func (db *DB) Session(config *Session) *DB {
tx.Config.NowFunc = config.NowFunc tx.Config.NowFunc = config.NowFunc
} }
if config.Initialized {
tx = tx.getInstance()
}
return tx return tx
} }