Skip to content

Commit

Permalink
Added tests from reported issues about Generics
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanrolds committed Jan 29, 2023
1 parent b2e9cfd commit 702b704
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
Empty file.
2 changes: 2 additions & 0 deletions testdata/sqlx_examples/expected_results.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# github.com/ryanrolds/sqlclosecheck/testdata/sqlx_examples
testdata/sqlx_examples/failure_generics.go:6:21: Rows/Stmt was not closed
testdata/sqlx_examples/failure_generics.go:13:21: Rows/Stmt was not closed
testdata/sqlx_examples/missing_close.go:10:24: Rows/Stmt was not closed
testdata/sqlx_examples/non_defer_close.go:30:12: Close should use defer
17 changes: 17 additions & 0 deletions testdata/sqlx_examples/failure_generics.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package sqlx_examples

import "database/sql"

func SqlCloseCheck(db *sql.DB, a int) {
rows, _ := db.Query("select id from tb") // <- detected OK
for rows.Next() {

}
}

func SqlCloseCheckG[T ~int64](db *sql.DB, a T) {
rows, _ := db.Query("select id from tb") // <- not detected KO
for rows.Next() {

}
}

0 comments on commit 702b704

Please sign in to comment.