summaryrefslogtreecommitdiff
path: root/sqlite.zig
diff options
context:
space:
mode:
Diffstat (limited to 'sqlite.zig')
-rw-r--r--sqlite.zig5
1 files changed, 5 insertions, 0 deletions
diff --git a/sqlite.zig b/sqlite.zig
index b1d5c7b..fd52691 100644
--- a/sqlite.zig
+++ b/sqlite.zig
@@ -2024,6 +2024,10 @@ pub fn Statement(comptime opts: StatementOptions, comptime query: ParsedQuery) t
2024 /// The types are checked at comptime. 2024 /// The types are checked at comptime.
2025 fn bind(self: *Self, options: anytype, values: anytype) !void { 2025 fn bind(self: *Self, options: anytype, values: anytype) !void {
2026 const StructType = @TypeOf(values); 2026 const StructType = @TypeOf(values);
2027 if (!comptime std.meta.trait.is(.Struct)(@TypeOf(values))) {
2028 @compileError("options passed to Statement.bind must be a struct (DynamicStatement supports runtime slices)");
2029 }
2030
2027 const StructTypeInfo = @typeInfo(StructType).Struct; 2031 const StructTypeInfo = @typeInfo(StructType).Struct;
2028 2032
2029 if (comptime query.nb_bind_markers != StructTypeInfo.fields.len) { 2033 if (comptime query.nb_bind_markers != StructTypeInfo.fields.len) {
@@ -3424,6 +3428,7 @@ test "sqlite: bind runtime slice" {
3424 try stmt.exec(.{}, args); 3428 try stmt.exec(.{}, args);
3425 } 3429 }
3426} 3430}
3431
3427test "sqlite: prepareDynamic" { 3432test "sqlite: prepareDynamic" {
3428 var arena = std.heap.ArenaAllocator.init(testing.allocator); 3433 var arena = std.heap.ArenaAllocator.init(testing.allocator);
3429 defer arena.deinit(); 3434 defer arena.deinit();