From 7984ca1560af16468edd4752d0c83d394726ec5f Mon Sep 17 00:00:00 2001 From: Vincent Rischmann Date: Wed, 30 Dec 2020 15:24:34 +0100 Subject: store the database handle in Iterator and Statement --- sqlite.zig | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sqlite.zig') diff --git a/sqlite.zig b/sqlite.zig index e1e3216..feb0295 100644 --- a/sqlite.zig +++ b/sqlite.zig @@ -456,6 +456,7 @@ pub fn Iterator(comptime Type: type) type { const TypeInfo = @typeInfo(Type); + db: *c.sqlite3, stmt: *c.sqlite3_stmt, // next scans the next row using the prepared statement. @@ -843,6 +844,7 @@ pub fn Statement(comptime opts: StatementOptions, comptime query: ParsedQuery) t return struct { const Self = @This(); + db: *c.sqlite3, stmt: *c.sqlite3_stmt, fn prepare(db: *Db, flags: c_uint) !Self { @@ -865,6 +867,7 @@ pub fn Statement(comptime opts: StatementOptions, comptime query: ParsedQuery) t }; return Self{ + .db = db.db, .stmt = stmt, }; } @@ -1010,6 +1013,7 @@ pub fn Statement(comptime opts: StatementOptions, comptime query: ParsedQuery) t self.bind(values); var res: Iterator(Type) = undefined; + res.db = self.db; res.stmt = self.stmt; return res; -- cgit v1.2.3