fix(archive): patch the sqlite driver to solve results inconsistencies

This commit is contained in:
Lorenzo Delgado 2022-11-24 18:59:25 +01:00 committed by GitHub
parent 43fd11b4dc
commit 41b2f87f68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -127,10 +127,15 @@ template prepare*(env: Sqlite, q: string, cleanup: untyped): ptr sqlite3_stmt =
proc bindParam*(s: RawStmtPtr, n: int, val: auto): cint =
when val is openarray[byte]|seq[byte]:
# The constant, SQLITE_TRANSIENT, may be passed to indicate that the object is to be copied
# prior to the return from sqlite3_bind_*(). The object and pointer to it must remain valid
# until then. SQLite will then manage the lifetime of its private copy.
#
# From: https://www.sqlite.org/c3ref/bind_blob.html
if val.len > 0:
sqlite3_bind_blob(s, n.cint, unsafeAddr val[0], val.len.cint, nil)
sqlite3_bind_blob(s, n.cint, unsafeAddr val[0], val.len.cint, SQLITE_TRANSIENT)
else:
sqlite3_bind_blob(s, n.cint, nil, 0.cint, nil)
sqlite3_bind_blob(s, n.cint, nil, 0.cint, SQLITE_TRANSIENT)
elif val is int32:
sqlite3_bind_int(s, n.cint, val)
elif val is uint32: