Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Add new method RollbackIfNotCommit to TxOrm interface #4428

Closed
flycash opened this issue Jan 9, 2021 · 2 comments · Fixed by #4542
Closed

Proposal: Add new method RollbackIfNotCommit to TxOrm interface #4428

flycash opened this issue Jan 9, 2021 · 2 comments · Fixed by #4542
Assignees

Comments

@flycash
Copy link
Collaborator

flycash commented Jan 9, 2021

In work, I found that I write code looks like:

tx := o.Begin()

// ..
if err != nil {
    tx.Rollback()
    return
}

if err1 != nil {
   tx.Rollback()
   return.
}

So I proposal that add new method named RollbackIfNotCommit, so I am able to write code like:

tx := o.Begin()
defer tx.RollbackIfNotCommit
// ..
if err != nil {
    return
}

if err1 != nil {
   return.
}

tx.Commit()
@liaoyijun
Copy link

@jianzhiyao i can try

@flycash flycash assigned liaoyijun and unassigned jianzhiyao Jan 27, 2021
@flycash
Copy link
Collaborator Author

flycash commented Jan 27, 2021

@liaoyijun I assigned it to you, :)

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 a pull request may close this issue.

3 participants