| 437 | } |
| 438 | |
| 439 | func TestConnQueryNull(t *testing.T) { |
| 440 | testWithAllQueryExecModes(t, func(t *testing.T, db *sql.DB) { |
| 441 | rows, err := db.Query("select $1::int", nil) |
| 442 | require.NoError(t, err) |
| 443 | |
| 444 | rowCount := int64(0) |
| 445 | |
| 446 | for rows.Next() { |
| 447 | rowCount++ |
| 448 | |
| 449 | var n sql.NullInt64 |
| 450 | err := rows.Scan(&n) |
| 451 | require.NoError(t, err) |
| 452 | if n.Valid != false { |
| 453 | t.Errorf("Expected n to be null, but it was %v", n) |
| 454 | } |
| 455 | } |
| 456 | require.NoError(t, rows.Err()) |
| 457 | require.EqualValues(t, 1, rowCount) |
| 458 | |
| 459 | err = rows.Close() |
| 460 | require.NoError(t, err) |
| 461 | }) |
| 462 | } |
| 463 | |
| 464 | func TestConnQueryRowByteSlice(t *testing.T) { |
| 465 | testWithAllQueryExecModes(t, func(t *testing.T, db *sql.DB) { |