pgx.ErrNoRows does not match err returned by query

7.4k views Asked by At

New at pgx. Using pgxpool. I have a simple Query

var result string
err := Conn.QueryRow(context.Background(),
    `SELECT name FROM table WHERE id=1000`).Scan(&result)

if err != nil {
    if err == pgx.ErrNoRows {
        fmt.Println("No Rows")
        fmt.Println(err)
    } else {
        fmt.Println("Other Error")
        fmt.Println(err)
    }
}

I am never getting "No Rows" even though No Rows are actually being returned. The err is ALWAYS "no rows in result set" but it never matches pgx.ErrNoRows, as I understood they are supposed to be the same.

On checking Types, pgx.ErrNoRows = *errors.fundamental while err = *xerrors.errorString.

What am I doing or assuming worng?

EDIT:

As @mkopriva mentioned below, the Problem is goimport automatically imports the wrong pgx, it needs to be "github.com/jackc/pgx/v4"

0

There are 0 answers