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

Flagging returned rows #32

Open
bentcoder opened this issue Nov 21, 2023 · 0 comments
Open

Flagging returned rows #32

bentcoder opened this issue Nov 21, 2023 · 0 comments

Comments

@bentcoder
Copy link

Hi,

Both Query calls in the function gets flagged. I cannot close the rows in this function because I am reading and closing it in actual caller function instead. Is this expected behaviour?

Thanks

import (
	"context"
	"errors"

	"github.com/jackc/pgx/v5"
	"github.com/jackc/pgx/v5/pgconn"
	"github.com/jackc/pgx/v5/pgxpool"
)

type Query struct {
	TXN pgx.Tx
	DTB    *pgxpool.Pool
}

func (q Query) Run(ctx context.Context, sql string, args ...any) (pgx.Rows, error) {
	switch {
	case q.TXN != nil:
		return q.TXN.Query(ctx, sql, args...)
	case q.DTB != nil:
		return q.DTB.Query(ctx, sql, args...)
	}

	return nil, errors.New("missing runner")
}
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

1 participant