-
Notifications
You must be signed in to change notification settings - Fork 628
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
db.go: return t.Rollback directly in the end of View function #41
Conversation
Codecov Report
@@ Coverage Diff @@
## master #41 +/- ##
=========================================
Coverage ? 84.91%
=========================================
Files ? 9
Lines ? 1849
Branches ? 0
=========================================
Hits ? 1570
Misses ? 166
Partials ? 113
Continue to review full report at Codecov.
|
@@ -687,9 +687,7 @@ func (db *DB) View(fn func(*Tx) error) error { | |||
return err | |||
} | |||
|
|||
if err := t.Rollback(); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the intent here is to avoid using unexported functions across object boundaries to avoid tight coupling.
It'd probably be better to have:
return t.Rollback()
}
which would directly correspond with the Update
code. Rollback
is the method for closing read-only transactions; close
is atypical.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense to me. tx.close
is tx's own function. And return t.Rollback()
matches return t.Commit()
in Update
function.
I'll update this commit later.
Make return line of db.View corresponding with db.Update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm thanks
lgtm |
Calling t.Rollback is a little bit misleading in the end of View function, since this tx has succeeded. What t.Rollback actually does here is closing this tx. So close tx directly.