diff options
| author | 2020-10-25 00:33:40 +0200 | |
|---|---|---|
| committer | 2020-10-25 00:33:40 +0200 | |
| commit | 3a0423c600db39b8d939b02d30f38eb82a00b08b (patch) | |
| tree | 314ec8c73f42ca7c7564e88650aac6f3f272af39 | |
| parent | add readme (diff) | |
| download | zig-sqlite-3a0423c600db39b8d939b02d30f38eb82a00b08b.tar.gz zig-sqlite-3a0423c600db39b8d939b02d30f38eb82a00b08b.tar.xz zig-sqlite-3a0423c600db39b8d939b02d30f38eb82a00b08b.zip | |
check the type of the options argument
Diffstat (limited to '')
| -rw-r--r-- | sqlite.zig | 6 |
1 files changed, 6 insertions, 0 deletions
| @@ -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); |