Open junsred opened 9 months ago
I'm curious on this one, too; CC @hallabro who worked on this originally in #25.
Pgx apparently closes rows when all rows are read and I guess because of this defer seems not needed.
I'm seeing the same behaviour. Worthy to note this is not a feature of pgx
- but default behaviour of database/sql
.
Personally, I'd rather not see for rows.Next() {}
be considered "OK" if that's the case - would rather have an defer rs.Close()
in-place regardless - e.g. you might return
inside the for
loop/etc. making the defer pretty critical.
But this shouldn't be the case since function might stop before iterating all the rows.
exactly 👍
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?
Code below does not give any errs