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

About the scope of the pgx linter #36

Open
junsred opened this issue Feb 17, 2024 · 0 comments
Open

About the scope of the pgx linter #36

junsred opened this issue Feb 17, 2024 · 0 comments

Comments

@junsred
Copy link

junsred commented Feb 17, 2024

Pgx apparently closes rows when all rows are read and I guess because of this defer seems not needed. But this shouldn't be the case since function might stop before iterating all the rows. Is this a bug or feature?

	// Next prepares the next row for reading. It returns true if there is another
	// row and false if no more rows are available. It automatically closes rows
	// when all rows are read.
	Next() bool

Code below does not give any errs

var pgxPool *pgxpool.Pool
func missingClosePgxPool() {
	rows, err := pgxPool.Query(context.Background(), "SELECT username FROM users") // want "Rows/Stmt/NamedStmt was not closed"
	if err != nil {
		log.Fatal(err)
	}

	for rows.Next() {
        }
}
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

1 participant