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

Support RollbackUnlessCommit #4542

Merged
merged 2 commits into from
Mar 22, 2021
Merged

Support RollbackUnlessCommit #4542

merged 2 commits into from
Mar 22, 2021

Conversation

flycash
Copy link
Collaborator

@flycash flycash commented Mar 21, 2021

In order to make handle transaction manually more easily, I provide a new API named RollbackUnlessCommit, it was inspired by gorm v1. And I think it could reduce such code:

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

I forget to call Rollback several times when I used beego Orm.
Now, I can write code looks like:

tx := o.Begin()
defer tx.RollbackUnlessCommit()

Close #4428

@sonarcloud
Copy link

sonarcloud bot commented Mar 21, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
1.9% 1.9% Duplication

@codecov-io
Copy link

codecov-io commented Mar 21, 2021

Codecov Report

Merging #4542 (629d592) into develop (9dc4ed8) will increase coverage by 0.01%.
The diff coverage is 63.20%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #4542      +/-   ##
===========================================
+ Coverage    54.35%   54.37%   +0.01%     
===========================================
  Files          235      237       +2     
  Lines        17322    17422     +100     
===========================================
+ Hits          9416     9473      +57     
- Misses        6985     7019      +34     
- Partials       921      930       +9     
Impacted Files Coverage Δ
client/orm/filter_orm_decorator.go 86.62% <0.00%> (-3.31%) ⬇️
client/orm/models_info_f.go 66.90% <ø> (ø)
client/orm/models_info_m.go 35.80% <ø> (-2.47%) ⬇️
core/logs/file.go 65.82% <ø> (ø)
core/logs/log.go 46.53% <ø> (ø)
core/validation/validation.go 62.73% <ø> (ø)
server/web/config.go 54.32% <ø> (ø)
server/web/controller.go 25.60% <0.00%> (-0.42%) ⬇️
server/web/filter/apiauth/apiauth.go 28.30% <ø> (ø)
server/web/router.go 67.53% <ø> (ø)
... and 19 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 88c5229...629d592. Read the comment docs.

@flycash flycash merged commit 10ea897 into beego:develop Mar 22, 2021
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.

Proposal: Add new method RollbackIfNotCommit to TxOrm interface
2 participants