diff options
Diffstat (limited to '')
| -rw-r--r-- | sqlite.zig | 5 |
1 files changed, 5 insertions, 0 deletions
| @@ -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 | |||
| 3427 | test "sqlite: prepareDynamic" { | 3432 | test "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(); |