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

Add ability to check closing of transactions #2

Open
agnivade opened this issue Apr 4, 2019 · 3 comments
Open

Add ability to check closing of transactions #2

agnivade opened this issue Apr 4, 2019 · 3 comments

Comments

@agnivade
Copy link

agnivade commented Apr 4, 2019

Hi, thanks for creating this. I would love to use this tool if this supports checking transactions too. Usually, rows.Close() is something that is not missed. But I miss closing transactions often.

I would want to check that transactions are always either committed or rolled back before the function returns.

Something like

tx, err := db.Begin()
if err != nil {
	return err
}
err = doSomething()
if err != nil {
	tx.Rollback()
	return err
}
return nil // error !! We are not doing tx.Commit() before returning.

Will it be possible to add something like this ? Thanks.

@timakin
Copy link
Contributor

timakin commented Apr 4, 2019

@agnivade
Thank you for a nice proposal.

First, this package is only for the validation of *sql.Rows.
But in the future, with other analyzers, we'll mix them to check broad use-cases of database/sql

For this reason, I'm sorry I won't implement the checker of database transaction commit in this package.
However, I definitely support this with creating another analyzer as soon as possible!
So I keep this issue opened. Thanks.

@agnivade
Copy link
Author

agnivade commented Apr 4, 2019

Great, thanks !

@jstangroome
Copy link

If a common pattern is eventually established for checking for closing of both Rows and Transactions then the next logical check would be closing Prepared Statements.

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

No branches or pull requests

3 participants