From 2ed8e991b543156dbf3faf0d000e1cfc168498d2 Mon Sep 17 00:00:00 2001 From: andri lim Date: Thu, 3 Aug 2023 22:00:47 +0700 Subject: [PATCH] add mixin env to sqlite3 generic procs (#627) --- eth/db/kvstore_sqlite3.nim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/eth/db/kvstore_sqlite3.nim b/eth/db/kvstore_sqlite3.nim index adc3220..1afffd9 100644 --- a/eth/db/kvstore_sqlite3.nim +++ b/eth/db/kvstore_sqlite3.nim @@ -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)