You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When calling getRow and no results are returned, postgres will issue a warning message to stderr : "row number 0 is out of range 0..-1". Other than the warning, there doesn't appear to be any problems caused by this, so its a minor issue.
let row = db.getRow(sql"select * from some_table where 1 = 2")
# "row number 0 is out of range 0..-1" printed to stderr
This is happening because setRow is called without checking if there are any rows returned. The following changes resolve the issue by calling pqntuples to check how many rows were returned.
--- /tmp/original_db_postgres.nim 2019-07-24 16:35:38.000000000 -0700+++ /nim-0.20.0/lib/impure/db_postgres.nim 2019-07-24 16:36:44.000000000 -0700@@ -392,7 +392,8 @@
var res = setupQuery(db, query, args)
var L = pqnfields(res)
result = newRow(L)
- setRow(res, result, 0, L)+ if pqntuples(res) > 0:+ setRow(res, result, 0, L)
pqclear(res)
proc getRow*(db: DbConn, stmtName: SqlPrepared,
@@ -400,7 +401,8 @@
var res = setupQuery(db, stmtName, args)
var L = pqNfields(res)
result = newRow(L)
- setRow(res, result, 0, L)+ if pqntuples(res) > 0:+ setRow(res, result, 0, L)
pqClear(res)
proc getAllRows*(db: DbConn, query: SqlQuery,
If no one sees any issues with that, I will make a pull request for this.
The text was updated successfully, but these errors were encountered:
When calling
getRow
and no results are returned, postgres will issue a warning message to stderr : "row number 0 is out of range 0..-1". Other than the warning, there doesn't appear to be any problems caused by this, so its a minor issue.This is happening because
setRow
is called without checking if there are any rows returned. The following changes resolve the issue by callingpqntuples
to check how many rows were returned.If no one sees any issues with that, I will make a pull request for this.
The text was updated successfully, but these errors were encountered: