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

db.go: return t.Rollback directly in the end of View function #41

Merged
merged 1 commit into from
Sep 12, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -687,11 +687,7 @@ func (db *DB) View(fn func(*Tx) error) error {
return err
}

if err := t.Rollback(); err != nil {
Copy link
Contributor

@heyitsanthony heyitsanthony Sep 12, 2017

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.

Copy link
Contributor Author

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.

return err
}

return nil
return t.Rollback()
}

// Batch calls fn as part of a batch. It behaves similar to Update,
Expand Down