Skip to content

Commit

Permalink
[-] fix for nil pointer exception when using .Kind() and closing the …
Browse files Browse the repository at this point in the history
…rows (#197)

Co-authored-by: Sven Buijsrogge <[email protected]>
  • Loading branch information
svennis94 and Sven Buijsrogge authored Apr 18, 2024
1 parent c918f49 commit b36a126
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion rows.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ func (rs *rowSets) FieldDescriptions() []pgconn.FieldDescription {
// }

func (rs *rowSets) Close() {
rs.ex.rowsWereClosed = true
if rs.ex != nil {
rs.ex.rowsWereClosed = true
}
// return rs.sets[rs.pos].closeErr
}

Expand Down
4 changes: 4 additions & 0 deletions rows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,10 @@ func TestRowsKind(t *testing.T) {
t.Fatalf("expected %s, but got %s", alphabet[i], letter)
}
}

// Test closing as this is called by the pgx library in pgx.CollectRows
// Previously this caused a nil pointer exception when Close was called on kindRows
kindRows.Close()
}

// TestConnRow tests the ConnRow interface implementation for Conn.QueryRow.
Expand Down

0 comments on commit b36a126

Please sign in to comment.