From 1863548676fe1eec5bb351a443619fca8db34661 Mon Sep 17 00:00:00 2001 From: samooth Date: Thu, 10 Sep 2026 19:34:40 +0200 Subject: [PATCH] fix: DynamicStatement.all ArrayList initialization DynamicStatement.all initialized std.ArrayList(Type) with = .{} but the unmanaged ArrayList has no default field values on Zig 0.16, causing a compilation error. Statement.all (the static counterpart) already used = .empty; this makes the dynamic path consistent. Adds a regression test for DynamicStatement.all which had zero coverage. --- sqlite.zig | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/sqlite.zig b/sqlite.zig index 429edcc..1e11e0d 100644 --- a/sqlite.zig +++ b/sqlite.zig @@ -1951,7 +1951,7 @@ pub const DynamicStatement = struct { pub fn all(self: *Self, comptime Type: type, allocator: mem.Allocator, options: QueryOptions, values: anytype) ![]Type { var iter = try self.iteratorAlloc(Type, allocator, values); - var rows: std.ArrayList(Type) = .{}; + var rows: std.ArrayList(Type) = .empty; while (try iter.nextAlloc(allocator, options)) |row| { try rows.append(allocator, row); } @@ -3558,6 +3558,24 @@ test "sqlite: oneDynamic" { } } +test "sqlite: dynamic statement all" { + var arena = std.heap.ArenaAllocator.init(testing.allocator); + defer arena.deinit(); + const allocator = arena.allocator(); + + var db = try getTestDb(); + defer db.deinit(); + try addTestData(&db); + + var stmt = try db.prepareDynamic("SELECT id FROM user WHERE age = ?"); + defer stmt.deinit(); + + const rows = try stmt.all(usize, allocator, .{}, .{ .age = 33 }); + defer allocator.free(rows); + try testing.expectEqual(@as(usize, 1), rows.len); + try testing.expectEqual(@as(usize, 20), rows[0]); +} + test "sqlite: one with all named parameters" { var db = try getTestDb(); defer db.deinit();