summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vincent Rischmann2020-10-24 23:16:03 +0200
committerGravatar Vincent Rischmann2020-10-24 23:16:03 +0200
commitd96ca64c5d5402765eb217c35f1ecab4b6edd89c (patch)
tree2c6ad0c8d389fdd38545cd2a2be26d7f7c25cc32
parentremove the src directory (diff)
downloadzig-sqlite-d96ca64c5d5402765eb217c35f1ecab4b6edd89c.tar.gz
zig-sqlite-d96ca64c5d5402765eb217c35f1ecab4b6edd89c.tar.xz
zig-sqlite-d96ca64c5d5402765eb217c35f1ecab4b6edd89c.zip
sqlite: fix default mode
-rw-r--r--sqlite.zig8
1 files changed, 7 insertions, 1 deletions
diff --git a/sqlite.zig b/sqlite.zig
index 88888cf..8aaef3a 100644
--- a/sqlite.zig
+++ b/sqlite.zig
@@ -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
389test "sqlite: db init" {
390 var db: Db = undefined;
391 try db.init(testing.allocator, .{ .mode = dbMode() });
392 try db.init(testing.allocator, .{});
393}
394
389test "sqlite: statement exec" { 395test "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();