Skip to content

fix: begin transaction fail, rollback panic#6365

Merged
jinzhu merged 1 commit intogo-gorm:masterfrom
zhouit:fix_begin_fail_rollback_panic
May 31, 2023
Merged

fix: begin transaction fail, rollback panic#6365
jinzhu merged 1 commit intogo-gorm:masterfrom
zhouit:fix_begin_fail_rollback_panic

Conversation

@zhouit
Copy link
Copy Markdown
Contributor

@zhouit zhouit commented May 31, 2023

  • Do only one thing
  • Non breaking API changes
  • Tested

What did this pull request do?

fix begin transaction fail, rollback panic

User Case Description

tx = db.Begin()  // when begin error

err := tx.Where(sql).Update(m).Err
if err = nil{
  tx.Rollback()   // will panic
  return err
}

tx.Commit()

@jinzhu jinzhu merged commit 740f2be into go-gorm:master May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants