sqlrows
sqlrows copied to clipboard
Add ability to check closing of transactions
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.
@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.
Great, thanks !
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.