-
-
Notifications
You must be signed in to change notification settings - Fork 158
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
When using PGX and looking at this specific doc https://pkg.go.dev/github.com/jackc/pgx/v5#Conn.Query PGX will return rows if it can, but there might be an error on the rows object indicating the transaction has failed.
Inside of both NewScanContext(rows *sql.Rows)
and queryToSlice
the rows.Err()
is never checked, and thus is swallowed.
Environment (please complete the following information):
- OS: Linux
- Database: CockroachDB
- Database driver: PGX
- Jet version v2.11.1
Code snippet
I have no easily code snippet but repro steps are
testCTE := CTE("test_cte")
stmt := WITH(
testCTE.AS(
myTable.INSERT(myTable.Column).VALUES(whatever).
RETURNING(myTable.AllColumns)
)
)(
SELECT(myTable.AllColumns).FROM(testCTE)
)
tx := db.Begin()
var dest resultStruct
// This returns no error, and the dest has been filled (likely with nothing as there was nothing in the CTE).
// Assume an error occurred here for whatever reason, with CRDB we can get 40001 and other errors that want you to retry.
if err := stmt.Query(tx, &dest); err != nil {
return err
}
someOtherStmt := UPDATE(something)
// This errors out with a "Transaction has been aborted" error.
someOtherStmt.Exec(tx, nil)
Expected behavior
The error originally encountered in the first query on the transaction is returned instead of or with the data so that we can properly act on the different errors returned.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working