Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rows.go Scan() crashes after QueryRow() #6

Open
jlpettersson opened this issue Aug 22, 2022 · 1 comment
Open

rows.go Scan() crashes after QueryRow() #6

jlpettersson opened this issue Aug 22, 2022 · 1 comment

Comments

@jlpettersson
Copy link

When I do a QueryRow() query, the Scan() panics with this error:

index out of range [-1]

This seem to be related to this line 72:

for i, col := range r.rows[r.pos-1] {

where r.pos is 0.

@ncyellow
Copy link

ncyellow commented Dec 19, 2022

you need to add Next() call

this is a simple example

columns := []string{"id"}
pgxRows := pgxpoolmock.NewRows(columns).AddRow(100).ToPgxRows()
pgxRows.Next()

suite.mockPool.EXPECT().QueryRow(gomock.Any(), `
INSERT INTO "users"("login", "password")
VALUES ($1, $2)
returning "@users"`, user.Login, user.Password).Return(pgxRows)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants