summaryrefslogtreecommitdiff
path: root/sqlite.zig
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sqlite.zig16
1 files changed, 8 insertions, 8 deletions
diff --git a/sqlite.zig b/sqlite.zig
index 143c279..3c2471d 100644
--- a/sqlite.zig
+++ b/sqlite.zig
@@ -243,6 +243,9 @@ pub const DetailedError = struct {
243 message: []const u8, 243 message: []const u8,
244 244
245 pub fn format(self: @This(), comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void { 245 pub fn format(self: @This(), comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
246 _ = fmt;
247 _ = options;
248
246 _ = try writer.print("{{code: {}, message: {s}}}", .{ self.code, self.message }); 249 _ = try writer.print("{{code: {}, message: {s}}}", .{ self.code, self.message });
247 } 250 }
248}; 251};
@@ -443,7 +446,7 @@ pub const Db = struct {
443 } 446 }
444 447
445 /// prepareWithDiags is like `prepare` but takes an additional options argument. 448 /// prepareWithDiags is like `prepare` but takes an additional options argument.
446 pub fn prepareWithDiags(self: *Self, comptime query: []const u8, options: QueryOptions) !comptime blk: { 449 pub fn prepareWithDiags(self: *Self, comptime query: []const u8, options: QueryOptions) !blk: {
447 @setEvalBranchQuota(100000); 450 @setEvalBranchQuota(100000);
448 break :blk Statement(.{}, ParsedQuery.from(query)); 451 break :blk Statement(.{}, ParsedQuery.from(query));
449 } { 452 } {
@@ -466,7 +469,7 @@ pub const Db = struct {
466 /// This is done because we type check the bind parameters when executing the statement later. 469 /// This is done because we type check the bind parameters when executing the statement later.
467 /// 470 ///
468 /// If you want additional error information in case of failures, use `prepareWithDiags`. 471 /// If you want additional error information in case of failures, use `prepareWithDiags`.
469 pub fn prepare(self: *Self, comptime query: []const u8) !comptime blk: { 472 pub fn prepare(self: *Self, comptime query: []const u8) !blk: {
470 @setEvalBranchQuota(100000); 473 @setEvalBranchQuota(100000);
471 break :blk Statement(.{}, ParsedQuery.from(query)); 474 break :blk Statement(.{}, ParsedQuery.from(query));
472 } { 475 } {
@@ -732,12 +735,6 @@ pub fn Iterator(comptime Type: type) type {
732 // The options must contain an `allocator` field which will be used to create a copy of the data. 735 // The options must contain an `allocator` field which will be used to create a copy of the data.
733 fn readBytes(self: *Self, comptime BytesType: type, allocator: *mem.Allocator, _i: usize, comptime mode: ReadBytesMode) !BytesType { 736 fn readBytes(self: *Self, comptime BytesType: type, allocator: *mem.Allocator, _i: usize, comptime mode: ReadBytesMode) !BytesType {
734 const i = @intCast(c_int, _i); 737 const i = @intCast(c_int, _i);
735 const type_info = @typeInfo(BytesType);
736
737 var ret: BytesType = switch (BytesType) {
738 Text, Blob => .{ .data = "" },
739 else => try dupeWithSentinel(BytesType, allocator, ""),
740 };
741 738
742 switch (mode) { 739 switch (mode) {
743 .Blob => { 740 .Blob => {
@@ -918,6 +915,8 @@ pub const StatementOptions = struct {};
918/// Look at each function for more complete documentation. 915/// Look at each function for more complete documentation.
919/// 916///
920pub fn Statement(comptime opts: StatementOptions, comptime query: ParsedQuery) type { 917pub fn Statement(comptime opts: StatementOptions, comptime query: ParsedQuery) type {
918 _ = opts;
919
921 return struct { 920 return struct {
922 const Self = @This(); 921 const Self = @This();
923 922
@@ -1245,6 +1244,7 @@ fn addTestData(db: *Db) !void {
1245 1244
1246test "sqlite: db init" { 1245test "sqlite: db init" {
1247 var db = try getTestDb(); 1246 var db = try getTestDb();
1247 _ = db;
1248} 1248}
1249 1249
1250test "sqlite: db pragma" { 1250test "sqlite: db pragma" {