From 812e0b51a11812c8ed712462e13c3743fb85f7e9 Mon Sep 17 00:00:00 2001 From: Vincent Rischmann Date: Wed, 20 Aug 2025 01:16:42 +0200 Subject: all: fix for latest zig --- sqlite.zig | 33 +++++++++++++++++---------------- vtab.zig | 6 +++--- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/sqlite.zig b/sqlite.zig index 7b2cd99..8a000aa 100644 --- a/sqlite.zig +++ b/sqlite.zig @@ -1967,7 +1967,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).init(allocator); + var rows: std.ArrayList(Type) = .{}; while (try iter.nextAlloc(allocator, options)) |row| { try rows.append(row); } @@ -2257,12 +2257,12 @@ pub fn Statement(comptime opts: StatementOptions, comptime query: anytype) type 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).init(allocator); + var rows: std.ArrayList(Type) = .{}; while (try iter.nextAlloc(allocator, options)) |row| { - try rows.append(row); + try rows.append(allocator, row); } - return rows.toOwnedSlice(); + return rows.toOwnedSlice(allocator); } }; } @@ -3020,13 +3020,13 @@ test "sqlite: statement iterator" { var stmt = try db.prepare("INSERT INTO user(name, id, age, weight, favorite_color) VALUES(?{[]const u8}, ?{usize}, ?{usize}, ?{f32}, ?{[]const u8})"); defer stmt.deinit(); - var expected_rows = std.ArrayList(TestUser).init(allocator); + var expected_rows: std.ArrayList(TestUser) = .{}; var i: usize = 0; while (i < 20) : (i += 1) { const name = try std.fmt.allocPrint(allocator, "Vincent {d}", .{i}); const user = TestUser{ .id = i, .name = name, .age = i + 200, .weight = @floatFromInt(i + 200), .favorite_color = .indigo }; - try expected_rows.append(user); + try expected_rows.append(allocator, user); stmt.reset(); try stmt.exec(.{}, user); @@ -3047,9 +3047,9 @@ test "sqlite: statement iterator" { var iter = try stmt2.iterator(RowType, .{}); - var rows = std.ArrayList(RowType).init(allocator); + var rows: std.ArrayList(RowType) = .{}; while (try iter.next(.{})) |row| { - try rows.append(row); + try rows.append(allocator, row); } // Check the data @@ -3074,9 +3074,9 @@ test "sqlite: statement iterator" { var iter = try stmt2.iterator(RowType, .{}); - var rows = std.ArrayList(RowType).init(allocator); + var rows: std.ArrayList(RowType) = .{}; while (try iter.nextAlloc(allocator, .{})) |row| { - try rows.append(row); + try rows.append(allocator, row); } // Check the data @@ -3459,10 +3459,10 @@ test "sqlite: bind runtime slice" { const allocator = arena.allocator(); // creating array list on heap so that it's deemed runtime size - var list = std.ArrayList([]const u8).init(allocator); - defer list.deinit(); - try list.append("this is some data"); - const args = try list.toOwnedSlice(); + var list: std.ArrayList([]const u8) = .{}; + defer list.deinit(allocator); + try list.append(allocator, "this is some data"); + const args = try list.toOwnedSlice(allocator); var db = try getTestDb(); defer db.deinit(); @@ -3871,13 +3871,14 @@ test "sqlite: create aggregate function with an aggregate context" { test "sqlite: empty slice" { 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 list = std.ArrayList(u8).init(arena.allocator()); - const ptr = try list.toOwnedSlice(); + var list: std.ArrayList(u8) = .{}; + const ptr = try list.toOwnedSlice(allocator); try db.exec("INSERT INTO article(author_id, data) VALUES(?, ?)", .{}, .{ 1, ptr }); diff --git a/vtab.zig b/vtab.zig index 539fcc4..19826d0 100644 --- a/vtab.zig +++ b/vtab.zig @@ -210,7 +210,7 @@ pub const BestIndexBuilder = struct { const res = Self{ .allocator = allocator, .index_info = index_info, - .id_str_buffer = std.ArrayList(u8).init(allocator), + .id_str_buffer = .empty, .constraints = try allocator.alloc(Constraint, @intCast(index_info.nConstraint)), .columns_used = @intCast(index_info.colUsed), .id = .{}, @@ -1070,7 +1070,7 @@ const TestVirtualTable = struct { _ = self; _ = diags; - var id_str_writer = builder.id_str_buffer.writer(); + var id_str_writer = builder.id_str_buffer.writer(builder.allocator); var argv_index: i32 = 0; for (builder.constraints) |*constraint| { @@ -1084,7 +1084,7 @@ const TestVirtualTable = struct { // - builder.id.str = try builder.id_str_buffer.toOwnedSlice(); + builder.id.str = try builder.id_str_buffer.toOwnedSlice(builder.allocator); builder.estimated_cost = 200; builder.estimated_rows = 200; -- cgit v1.2.3