Replies: 3 comments
-
I made an enhancement request. I think this should be done as adding a new annotation. I don't think |
Beta Was this translation helpful? Give feedback.
-
What do you want to change? Pgx now supports CollectExactlyOneRow. This returns error when there is more than 1 resulting row, but doesn't fetch them all. This could be done by either modifying :one behaviour, or adding :exactlyone annotation. I think adding :exactlyone annotation is better, because erroring on :one on select where sqlc currently doesn't error is backwards incompatible change, and it doesn't strike me as correct anyway (:one can mean I actually want the first from many, see the pgx thread). See: jackc/pgx#1411 (comment) If this is desired, I can take a shot at this feature and try to add it myself since it doesn't strike me as that hard (and, sqlc already has annotations that are just for go and just for pgx), but, let's see :) |
Beta Was this translation helpful? Give feedback.
-
@karelbilek I closed your issue, mainly so that we can continue the discussion here before we decide on anything.
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using sqlc with pgx/v5 in go, for a delete query with :one annotation for eg.
I was expecting it to fail with
pgx.ErrTooManyRows
if the query returns more than one row but what i found was it picks the first row and just ignores the rest. sqlc codegen for pgx usesQueryRow
method of pgx which has the behavior of ignoring all the rows but one if there are multiple, would it be possible to useQuery
along withCollectExactlyOneRow
in place ofQueryRow
(jackc/pgx#1411 (comment)) ?sqlc/internal/codegen/golang/templates/pgx/queryCode.tmpl
Lines 26 to 47 in 34f8c1b
Beta Was this translation helpful? Give feedback.
All reactions