diff options
| author | 2020-10-24 23:16:03 +0200 | |
|---|---|---|
| committer | 2020-10-24 23:16:03 +0200 | |
| commit | d96ca64c5d5402765eb217c35f1ecab4b6edd89c (patch) | |
| tree | 2c6ad0c8d389fdd38545cd2a2be26d7f7c25cc32 /sqlite.zig | |
| parent | remove the src directory (diff) | |
| download | zig-sqlite-d96ca64c5d5402765eb217c35f1ecab4b6edd89c.tar.gz zig-sqlite-d96ca64c5d5402765eb217c35f1ecab4b6edd89c.tar.xz zig-sqlite-d96ca64c5d5402765eb217c35f1ecab4b6edd89c.zip | |
sqlite: fix default mode
Diffstat (limited to '')
| -rw-r--r-- | sqlite.zig | 8 |
1 files changed, 7 insertions, 1 deletions
| @@ -37,7 +37,7 @@ pub const Db = struct { | |||
| 37 | pub fn init(self: *Self, allocator: *mem.Allocator, options: anytype) !void { | 37 | pub fn init(self: *Self, allocator: *mem.Allocator, options: anytype) !void { |
| 38 | self.allocator = allocator; | 38 | self.allocator = allocator; |
| 39 | 39 | ||
| 40 | const mode = if (@hasField(@TypeOf(options), "mode")) options.mode else .Memory; | 40 | const mode: Mode = if (@hasField(@TypeOf(options), "mode")) options.mode else .Memory; |
| 41 | 41 | ||
| 42 | switch (mode) { | 42 | switch (mode) { |
| 43 | .File => |path| { | 43 | .File => |path| { |
| @@ -386,6 +386,12 @@ pub const Statement = struct { | |||
| 386 | } | 386 | } |
| 387 | }; | 387 | }; |
| 388 | 388 | ||
| 389 | test "sqlite: db init" { | ||
| 390 | var db: Db = undefined; | ||
| 391 | try db.init(testing.allocator, .{ .mode = dbMode() }); | ||
| 392 | try db.init(testing.allocator, .{}); | ||
| 393 | } | ||
| 394 | |||
| 389 | test "sqlite: statement exec" { | 395 | test "sqlite: statement exec" { |
| 390 | var arena = std.heap.ArenaAllocator.init(testing.allocator); | 396 | var arena = std.heap.ArenaAllocator.init(testing.allocator); |
| 391 | defer arena.deinit(); | 397 | defer arena.deinit(); |