diff options
| author | 2020-12-30 15:24:34 +0100 | |
|---|---|---|
| committer | 2021-02-27 00:42:39 +0100 | |
| commit | 7984ca1560af16468edd4752d0c83d394726ec5f (patch) | |
| tree | 7d29803d258d16ba942028dae09925ce02df92c5 /sqlite.zig | |
| parent | Merge pull request #10 from vrischmann/incremental-blob-io (diff) | |
| download | zig-sqlite-7984ca1560af16468edd4752d0c83d394726ec5f.tar.gz zig-sqlite-7984ca1560af16468edd4752d0c83d394726ec5f.tar.xz zig-sqlite-7984ca1560af16468edd4752d0c83d394726ec5f.zip | |
store the database handle in Iterator and Statement
Diffstat (limited to 'sqlite.zig')
| -rw-r--r-- | sqlite.zig | 4 |
1 files changed, 4 insertions, 0 deletions
| @@ -456,6 +456,7 @@ pub fn Iterator(comptime Type: type) type { | |||
| 456 | 456 | ||
| 457 | const TypeInfo = @typeInfo(Type); | 457 | const TypeInfo = @typeInfo(Type); |
| 458 | 458 | ||
| 459 | db: *c.sqlite3, | ||
| 459 | stmt: *c.sqlite3_stmt, | 460 | stmt: *c.sqlite3_stmt, |
| 460 | 461 | ||
| 461 | // next scans the next row using the prepared statement. | 462 | // next scans the next row using the prepared statement. |
| @@ -843,6 +844,7 @@ pub fn Statement(comptime opts: StatementOptions, comptime query: ParsedQuery) t | |||
| 843 | return struct { | 844 | return struct { |
| 844 | const Self = @This(); | 845 | const Self = @This(); |
| 845 | 846 | ||
| 847 | db: *c.sqlite3, | ||
| 846 | stmt: *c.sqlite3_stmt, | 848 | stmt: *c.sqlite3_stmt, |
| 847 | 849 | ||
| 848 | fn prepare(db: *Db, flags: c_uint) !Self { | 850 | fn prepare(db: *Db, flags: c_uint) !Self { |
| @@ -865,6 +867,7 @@ pub fn Statement(comptime opts: StatementOptions, comptime query: ParsedQuery) t | |||
| 865 | }; | 867 | }; |
| 866 | 868 | ||
| 867 | return Self{ | 869 | return Self{ |
| 870 | .db = db.db, | ||
| 868 | .stmt = stmt, | 871 | .stmt = stmt, |
| 869 | }; | 872 | }; |
| 870 | } | 873 | } |
| @@ -1010,6 +1013,7 @@ pub fn Statement(comptime opts: StatementOptions, comptime query: ParsedQuery) t | |||
| 1010 | self.bind(values); | 1013 | self.bind(values); |
| 1011 | 1014 | ||
| 1012 | var res: Iterator(Type) = undefined; | 1015 | var res: Iterator(Type) = undefined; |
| 1016 | res.db = self.db; | ||
| 1013 | res.stmt = self.stmt; | 1017 | res.stmt = self.stmt; |
| 1014 | 1018 | ||
| 1015 | return res; | 1019 | return res; |