MCPcopy
hub / github.com/jackc/pgx / TestConnQueryNull

Function TestConnQueryNull

stdlib/sql_test.go:439–462  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

437}
438
439func 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
464func TestConnQueryRowByteSlice(t *testing.T) {
465 testWithAllQueryExecModes(t, func(t *testing.T, db *sql.DB) {

Callers

nothing calls this directly

Calls 6

QueryMethod · 0.65
NextMethod · 0.65
ScanMethod · 0.65
ErrMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected