summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sqlite.zig6
1 files changed, 6 insertions, 0 deletions
diff --git a/sqlite.zig b/sqlite.zig
index 8aaef3a..46f2e7e 100644
--- a/sqlite.zig
+++ b/sqlite.zig
@@ -254,6 +254,9 @@ pub const Statement = struct {
254 /// an allocator used to read text and blobs. 254 /// an allocator used to read text and blobs.
255 /// 255 ///
256 pub fn one(self: *Self, comptime Type: type, options: anytype) !?Type { 256 pub fn one(self: *Self, comptime Type: type, options: anytype) !?Type {
257 if (!comptime std.meta.trait.is(.Struct)(@TypeOf(options))) {
258 @compileError("options passed to all must be a struct");
259 }
257 const TypeInfo = @typeInfo(Type); 260 const TypeInfo = @typeInfo(Type);
258 261
259 var result = c.sqlite3_step(self.stmt); 262 var result = c.sqlite3_step(self.stmt);
@@ -295,6 +298,9 @@ pub const Statement = struct {
295 /// Note that for this function the allocator is mandatory. 298 /// Note that for this function the allocator is mandatory.
296 /// 299 ///
297 pub fn all(self: *Self, comptime Type: type, options: anytype) ![]Type { 300 pub fn all(self: *Self, comptime Type: type, options: anytype) ![]Type {
301 if (!comptime std.meta.trait.is(.Struct)(@TypeOf(options))) {
302 @compileError("options passed to all must be a struct");
303 }
298 const TypeInfo = @typeInfo(Type); 304 const TypeInfo = @typeInfo(Type);
299 305
300 var rows = std.ArrayList(Type).init(options.allocator); 306 var rows = std.ArrayList(Type).init(options.allocator);