Skip to content

Commit 812e0b5

Browse files
committed
all: fix for latest zig
1 parent f21dbd4 commit 812e0b5

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

sqlite.zig

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1967,7 +1967,7 @@ pub const DynamicStatement = struct {
19671967
pub fn all(self: *Self, comptime Type: type, allocator: mem.Allocator, options: QueryOptions, values: anytype) ![]Type {
19681968
var iter = try self.iteratorAlloc(Type, allocator, values);
19691969

1970-
var rows = std.ArrayList(Type).init(allocator);
1970+
var rows: std.ArrayList(Type) = .{};
19711971
while (try iter.nextAlloc(allocator, options)) |row| {
19721972
try rows.append(row);
19731973
}
@@ -2257,12 +2257,12 @@ pub fn Statement(comptime opts: StatementOptions, comptime query: anytype) type
22572257
pub fn all(self: *Self, comptime Type: type, allocator: mem.Allocator, options: QueryOptions, values: anytype) ![]Type {
22582258
var iter = try self.iteratorAlloc(Type, allocator, values);
22592259

2260-
var rows = std.ArrayList(Type).init(allocator);
2260+
var rows: std.ArrayList(Type) = .{};
22612261
while (try iter.nextAlloc(allocator, options)) |row| {
2262-
try rows.append(row);
2262+
try rows.append(allocator, row);
22632263
}
22642264

2265-
return rows.toOwnedSlice();
2265+
return rows.toOwnedSlice(allocator);
22662266
}
22672267
};
22682268
}
@@ -3020,13 +3020,13 @@ test "sqlite: statement iterator" {
30203020
var stmt = try db.prepare("INSERT INTO user(name, id, age, weight, favorite_color) VALUES(?{[]const u8}, ?{usize}, ?{usize}, ?{f32}, ?{[]const u8})");
30213021
defer stmt.deinit();
30223022

3023-
var expected_rows = std.ArrayList(TestUser).init(allocator);
3023+
var expected_rows: std.ArrayList(TestUser) = .{};
30243024
var i: usize = 0;
30253025
while (i < 20) : (i += 1) {
30263026
const name = try std.fmt.allocPrint(allocator, "Vincent {d}", .{i});
30273027
const user = TestUser{ .id = i, .name = name, .age = i + 200, .weight = @floatFromInt(i + 200), .favorite_color = .indigo };
30283028

3029-
try expected_rows.append(user);
3029+
try expected_rows.append(allocator, user);
30303030

30313031
stmt.reset();
30323032
try stmt.exec(.{}, user);
@@ -3047,9 +3047,9 @@ test "sqlite: statement iterator" {
30473047

30483048
var iter = try stmt2.iterator(RowType, .{});
30493049

3050-
var rows = std.ArrayList(RowType).init(allocator);
3050+
var rows: std.ArrayList(RowType) = .{};
30513051
while (try iter.next(.{})) |row| {
3052-
try rows.append(row);
3052+
try rows.append(allocator, row);
30533053
}
30543054

30553055
// Check the data
@@ -3074,9 +3074,9 @@ test "sqlite: statement iterator" {
30743074

30753075
var iter = try stmt2.iterator(RowType, .{});
30763076

3077-
var rows = std.ArrayList(RowType).init(allocator);
3077+
var rows: std.ArrayList(RowType) = .{};
30783078
while (try iter.nextAlloc(allocator, .{})) |row| {
3079-
try rows.append(row);
3079+
try rows.append(allocator, row);
30803080
}
30813081

30823082
// Check the data
@@ -3459,10 +3459,10 @@ test "sqlite: bind runtime slice" {
34593459
const allocator = arena.allocator();
34603460

34613461
// creating array list on heap so that it's deemed runtime size
3462-
var list = std.ArrayList([]const u8).init(allocator);
3463-
defer list.deinit();
3464-
try list.append("this is some data");
3465-
const args = try list.toOwnedSlice();
3462+
var list: std.ArrayList([]const u8) = .{};
3463+
defer list.deinit(allocator);
3464+
try list.append(allocator, "this is some data");
3465+
const args = try list.toOwnedSlice(allocator);
34663466

34673467
var db = try getTestDb();
34683468
defer db.deinit();
@@ -3871,13 +3871,14 @@ test "sqlite: create aggregate function with an aggregate context" {
38713871
test "sqlite: empty slice" {
38723872
var arena = std.heap.ArenaAllocator.init(testing.allocator);
38733873
defer arena.deinit();
3874+
const allocator = arena.allocator();
38743875

38753876
var db = try getTestDb();
38763877
defer db.deinit();
38773878
try addTestData(&db);
38783879

3879-
var list = std.ArrayList(u8).init(arena.allocator());
3880-
const ptr = try list.toOwnedSlice();
3880+
var list: std.ArrayList(u8) = .{};
3881+
const ptr = try list.toOwnedSlice(allocator);
38813882

38823883
try db.exec("INSERT INTO article(author_id, data) VALUES(?, ?)", .{}, .{ 1, ptr });
38833884

vtab.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ pub const BestIndexBuilder = struct {
210210
const res = Self{
211211
.allocator = allocator,
212212
.index_info = index_info,
213-
.id_str_buffer = std.ArrayList(u8).init(allocator),
213+
.id_str_buffer = .empty,
214214
.constraints = try allocator.alloc(Constraint, @intCast(index_info.nConstraint)),
215215
.columns_used = @intCast(index_info.colUsed),
216216
.id = .{},
@@ -1070,7 +1070,7 @@ const TestVirtualTable = struct {
10701070
_ = self;
10711071
_ = diags;
10721072

1073-
var id_str_writer = builder.id_str_buffer.writer();
1073+
var id_str_writer = builder.id_str_buffer.writer(builder.allocator);
10741074

10751075
var argv_index: i32 = 0;
10761076
for (builder.constraints) |*constraint| {
@@ -1084,7 +1084,7 @@ const TestVirtualTable = struct {
10841084

10851085
//
10861086

1087-
builder.id.str = try builder.id_str_buffer.toOwnedSlice();
1087+
builder.id.str = try builder.id_str_buffer.toOwnedSlice(builder.allocator);
10881088
builder.estimated_cost = 200;
10891089
builder.estimated_rows = 200;
10901090

0 commit comments

Comments
 (0)