add mixin env to sqlite3 generic procs (#627)

This commit is contained in:
andri lim 2023-08-03 22:00:47 +07:00 committed by GitHub
parent d217d309eb
commit 2ed8e991b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -96,6 +96,7 @@ proc prepareStmt*(db: SqStoreRef,
Params: type,
Res: type,
managed = true): KvResult[SqliteStmt[Params, Res]] =
mixin env
var s: RawStmtPtr
checkErr db.env, sqlite3_prepare_v2(db.env, stmt, stmt.len.cint, addr s, nil)
if managed: db.managedStmts.add s
@ -128,6 +129,7 @@ proc bindParam(s: RawStmtPtr, n: int, val: auto): cint =
{.fatal: "Please add support for the '" & $typeof(val) & "' type".}
template bindParams(s: RawStmtPtr, params: auto) =
mixin env
when params is tuple:
when params.type.arity > 0:
var i = 1
@ -138,6 +140,7 @@ template bindParams(s: RawStmtPtr, params: auto) =
checkErr s.env, bindParam(s, 1, params)
proc exec*[P](s: SqliteStmt[P, void], params: P): KvResult[void] =
mixin env
let s = RawStmtPtr s
bindParams(s, params)