fix: ignore if not prepare stmt

This commit is contained in:
a631807682 2023-02-15 15:22:42 +08:00
parent 484d162023
commit 07d355c82d
No known key found for this signature in database
GPG Key ID: 137D1D75522168AB
2 changed files with 4 additions and 1 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@ _book
.idea .idea
vendor vendor
.vscode .vscode
.DS_Store

View File

@ -617,7 +617,9 @@ func (db *DB) Transaction(fc func(tx *DB) error, opts ...*sql.TxOptions) (err er
if committer, ok := db.Statement.ConnPool.(TxCommitter); ok && committer != nil { if committer, ok := db.Statement.ConnPool.(TxCommitter); ok && committer != nil {
// nested transaction // nested transaction
if !db.DisableNestedTransaction && (db.PrepareStmt && !db.DisablePrepareNestedTransaction) { if !db.DisableNestedTransaction && (!db.PrepareStmt ||
(db.PrepareStmt && !db.DisablePrepareNestedTransaction)) {
err = db.SavePoint(fmt.Sprintf("sp%p", fc)).Error err = db.SavePoint(fmt.Sprintf("sp%p", fc)).Error
if err != nil { if err != nil {
return return