summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vincent Rischmann2023-02-22 23:20:14 +0100
committerGravatar Vincent Rischmann2023-02-22 23:20:14 +0100
commit1333830fcf6b8e99bb0d9497ceaea79251e5195c (patch)
treecacca60e428ad150e021ec5cee0e27cd128e79f3
parentfix tests (diff)
downloadzig-sqlite-1333830fcf6b8e99bb0d9497ceaea79251e5195c.tar.gz
zig-sqlite-1333830fcf6b8e99bb0d9497ceaea79251e5195c.tar.xz
zig-sqlite-1333830fcf6b8e99bb0d9497ceaea79251e5195c.zip
fix for latest zig by running 'zig fmt'
Diffstat (limited to '')
-rw-r--r--sqlite.zig24
-rw-r--r--vtab.zig12
2 files changed, 18 insertions, 18 deletions
diff --git a/sqlite.zig b/sqlite.zig
index 1b39a04..77c30fc 100644
--- a/sqlite.zig
+++ b/sqlite.zig
@@ -748,7 +748,7 @@ pub const Db = struct {
748 const sqlite_args = argv[0..fn_info.params.len]; 748 const sqlite_args = argv[0..fn_info.params.len];
749 749
750 var fn_args: ArgTuple = undefined; 750 var fn_args: ArgTuple = undefined;
751 inline for (fn_info.params) |arg, i| { 751 inline for (fn_info.params, 0..) |arg, i| {
752 const ArgType = arg.type.?; 752 const ArgType = arg.type.?;
753 helpers.setTypeFromValue(ArgType, &fn_args[i], sqlite_args[i].?); 753 helpers.setTypeFromValue(ArgType, &fn_args[i], sqlite_args[i].?);
754 } 754 }
@@ -1395,7 +1395,7 @@ pub fn Iterator(comptime Type: type) type {
1395 1395
1396 var value: Type = undefined; 1396 var value: Type = undefined;
1397 1397
1398 inline for (@typeInfo(Type).Struct.fields) |field, _i| { 1398 inline for (@typeInfo(Type).Struct.fields, 0..) |field, _i| {
1399 const i = @as(usize, _i); 1399 const i = @as(usize, _i);
1400 1400
1401 const ret = try self.readField(field.type, options, i); 1401 const ret = try self.readField(field.type, options, i);
@@ -1721,7 +1721,7 @@ pub const DynamicStatement = struct {
1721 1721
1722 switch (@typeInfo(Type)) { 1722 switch (@typeInfo(Type)) {
1723 .Struct => |StructTypeInfo| { 1723 .Struct => |StructTypeInfo| {
1724 inline for (StructTypeInfo.fields) |struct_field, struct_field_i| { 1724 inline for (StructTypeInfo.fields, 0..) |struct_field, struct_field_i| {
1725 const field_value = @field(values, struct_field.name); 1725 const field_value = @field(values, struct_field.name);
1726 1726
1727 const i = sqlite3BindParameterIndex(self.stmt, struct_field.name); 1727 const i = sqlite3BindParameterIndex(self.stmt, struct_field.name);
@@ -1735,7 +1735,7 @@ pub const DynamicStatement = struct {
1735 .Pointer => |PointerTypeInfo| { 1735 .Pointer => |PointerTypeInfo| {
1736 switch (PointerTypeInfo.size) { 1736 switch (PointerTypeInfo.size) {
1737 .Slice => { 1737 .Slice => {
1738 for (values) |value_to_bind, index| { 1738 for (values, 0..) |value_to_bind, index| {
1739 try self.bindField(PointerTypeInfo.child, options, "unknown", @intCast(c_int, index), value_to_bind); 1739 try self.bindField(PointerTypeInfo.child, options, "unknown", @intCast(c_int, index), value_to_bind);
1740 } 1740 }
1741 }, 1741 },
@@ -1743,7 +1743,7 @@ pub const DynamicStatement = struct {
1743 } 1743 }
1744 }, 1744 },
1745 .Array => |ArrayTypeInfo| { 1745 .Array => |ArrayTypeInfo| {
1746 for (values) |value_to_bind, index| { 1746 for (values, 0..) |value_to_bind, index| {
1747 try self.bindField(ArrayTypeInfo.child, options, "unknown", @intCast(c_int, index), value_to_bind); 1747 try self.bindField(ArrayTypeInfo.child, options, "unknown", @intCast(c_int, index), value_to_bind);
1748 } 1748 }
1749 }, 1749 },
@@ -2025,7 +2025,7 @@ pub fn Statement(comptime opts: StatementOptions, comptime query: anytype) type
2025 })); 2025 }));
2026 } 2026 }
2027 2027
2028 inline for (StructTypeInfo.fields) |struct_field, _i| { 2028 inline for (StructTypeInfo.fields, 0..) |struct_field, _i| {
2029 const bind_marker = query.bind_markers[_i]; 2029 const bind_marker = query.bind_markers[_i];
2030 if (bind_marker.typed) |typ| { 2030 if (bind_marker.typed) |typ| {
2031 const FieldTypeInfo = @typeInfo(struct_field.type); 2031 const FieldTypeInfo = @typeInfo(struct_field.type);
@@ -2497,7 +2497,7 @@ test "sqlite: read all users into a struct" {
2497 2497
2498 var rows = try stmt.all(TestUser, allocator, .{}, .{}); 2498 var rows = try stmt.all(TestUser, allocator, .{}, .{});
2499 try testing.expectEqual(@as(usize, 3), rows.len); 2499 try testing.expectEqual(@as(usize, 3), rows.len);
2500 for (rows) |row, i| { 2500 for (rows, 0..) |row, i| {
2501 const exp = test_users[i]; 2501 const exp = test_users[i];
2502 try testing.expectEqual(exp.id, row.id); 2502 try testing.expectEqual(exp.id, row.id);
2503 try testing.expectEqualStrings(exp.name, row.name); 2503 try testing.expectEqualStrings(exp.name, row.name);
@@ -2828,7 +2828,7 @@ test "sqlite: bind pointer" {
2828 var stmt = try db.prepare(query); 2828 var stmt = try db.prepare(query);
2829 defer stmt.deinit(); 2829 defer stmt.deinit();
2830 2830
2831 for (test_users) |test_user, i| { 2831 for (test_users, 0..) |test_user, i| {
2832 stmt.reset(); 2832 stmt.reset();
2833 2833
2834 const name = try stmt.oneAlloc([]const u8, allocator, .{}, .{&test_user.id}); 2834 const name = try stmt.oneAlloc([]const u8, allocator, .{}, .{&test_user.id});
@@ -2864,7 +2864,7 @@ test "sqlite: read pointers" {
2864 ); 2864 );
2865 2865
2866 try testing.expectEqual(@as(usize, 3), rows.len); 2866 try testing.expectEqual(@as(usize, 3), rows.len);
2867 for (rows) |row, i| { 2867 for (rows, 0..) |row, i| {
2868 const exp = test_users[i]; 2868 const exp = test_users[i];
2869 try testing.expectEqual(exp.id, row.id.*); 2869 try testing.expectEqual(exp.id, row.id.*);
2870 try testing.expectEqualStrings(exp.name, row.name.*); 2870 try testing.expectEqualStrings(exp.name, row.name.*);
@@ -2998,7 +2998,7 @@ test "sqlite: statement iterator" {
2998 // Check the data 2998 // Check the data
2999 try testing.expectEqual(expected_rows.items.len, rows.items.len); 2999 try testing.expectEqual(expected_rows.items.len, rows.items.len);
3000 3000
3001 for (rows.items) |row, j| { 3001 for (rows.items, 0..) |row, j| {
3002 const exp_row = expected_rows.items[j]; 3002 const exp_row = expected_rows.items[j];
3003 try testing.expectEqualStrings(exp_row.name, mem.sliceTo(&row.name, 0)); 3003 try testing.expectEqualStrings(exp_row.name, mem.sliceTo(&row.name, 0));
3004 try testing.expectEqual(exp_row.age, row.age); 3004 try testing.expectEqual(exp_row.age, row.age);
@@ -3025,7 +3025,7 @@ test "sqlite: statement iterator" {
3025 // Check the data 3025 // Check the data
3026 try testing.expectEqual(expected_rows.items.len, rows.items.len); 3026 try testing.expectEqual(expected_rows.items.len, rows.items.len);
3027 3027
3028 for (rows.items) |row, j| { 3028 for (rows.items, 0..) |row, j| {
3029 const exp_row = expected_rows.items[j]; 3029 const exp_row = expected_rows.items[j];
3030 try testing.expectEqualStrings(exp_row.name, row.name.data); 3030 try testing.expectEqualStrings(exp_row.name, row.name.data);
3031 try testing.expectEqual(exp_row.age, row.age); 3031 try testing.expectEqual(exp_row.age, row.age);
@@ -3386,7 +3386,7 @@ test "sqlite: bind custom type" {
3386 const rows = try stmt.all(Article, arena.allocator(), .{}, .{}); 3386 const rows = try stmt.all(Article, arena.allocator(), .{}, .{});
3387 try testing.expectEqual(@as(usize, 20), rows.len); 3387 try testing.expectEqual(@as(usize, 20), rows.len);
3388 3388
3389 for (rows) |row, i| { 3389 for (rows, 0..) |row, i| {
3390 var exp_data: MyData = undefined; 3390 var exp_data: MyData = undefined;
3391 mem.set(u8, &exp_data.data, @intCast(u8, i)); 3391 mem.set(u8, &exp_data.data, @intCast(u8, i));
3392 3392
diff --git a/vtab.zig b/vtab.zig
index aef1b40..a7645c3 100644
--- a/vtab.zig
+++ b/vtab.zig
@@ -207,7 +207,7 @@ pub const BestIndexBuilder = struct {
207 .id = .{}, 207 .id = .{},
208 }; 208 };
209 209
210 for (res.constraints) |*constraint, i| { 210 for (res.constraints, 0..) |*constraint, i| {
211 const raw_constraint = index_info.aConstraint[i]; 211 const raw_constraint = index_info.aConstraint[i];
212 212
213 constraint.column = @intCast(isize, raw_constraint.iColumn); 213 constraint.column = @intCast(isize, raw_constraint.iColumn);
@@ -233,7 +233,7 @@ pub const BestIndexBuilder = struct {
233 233
234 // Populate the constraint usage 234 // Populate the constraint usage
235 var constraint_usage: []c.sqlite3_index_constraint_usage = index_info.aConstraintUsage[0..self.constraints.len]; 235 var constraint_usage: []c.sqlite3_index_constraint_usage = index_info.aConstraintUsage[0..self.constraints.len];
236 for (self.constraints) |constraint, i| { 236 for (self.constraints, 0..) |constraint, i| {
237 constraint_usage[i].argvIndex = constraint.usage.argv_index; 237 constraint_usage[i].argvIndex = constraint.usage.argv_index;
238 constraint_usage[i].omit = if (constraint.usage.omit) 1 else 0; 238 constraint_usage[i].omit = if (constraint.usage.omit) 1 else 0;
239 } 239 }
@@ -541,7 +541,7 @@ fn parseModuleArguments(allocator: mem.Allocator, argc: c_int, argv: [*c]const [
541 var res = try allocator.alloc(ModuleArgument, @intCast(usize, argc)); 541 var res = try allocator.alloc(ModuleArgument, @intCast(usize, argc));
542 errdefer allocator.free(res); 542 errdefer allocator.free(res);
543 543
544 for (res) |*marg, i| { 544 for (res, 0..) |*marg, i| {
545 // The documentation of sqlite says each string in argv is null-terminated 545 // The documentation of sqlite says each string in argv is null-terminated
546 const arg = mem.sliceTo(argv[i], 0); 546 const arg = mem.sliceTo(argv[i], 0);
547 547
@@ -840,7 +840,7 @@ pub fn VirtualTable(
840 const size = @intCast(usize, argc); 840 const size = @intCast(usize, argc);
841 841
842 var res = try allocator.alloc(FilterArg, size); 842 var res = try allocator.alloc(FilterArg, size);
843 for (res) |*item, i| { 843 for (res, 0..) |*item, i| {
844 item.* = .{ 844 item.* = .{
845 .value = argv[i], 845 .value = argv[i],
846 }; 846 };
@@ -1276,7 +1276,7 @@ test "parse module arguments" {
1276 const allocator = arena.allocator(); 1276 const allocator = arena.allocator();
1277 1277
1278 var args = try allocator.alloc([*c]const u8, 20); 1278 var args = try allocator.alloc([*c]const u8, 20);
1279 for (args) |*arg, i| { 1279 for (args, 0..) |*arg, i| {
1280 const tmp = try fmt.allocPrintZ(allocator, "arg={d}", .{i}); 1280 const tmp = try fmt.allocPrintZ(allocator, "arg={d}", .{i});
1281 arg.* = @ptrCast([*c]const u8, tmp); 1281 arg.* = @ptrCast([*c]const u8, tmp);
1282 } 1282 }
@@ -1288,7 +1288,7 @@ test "parse module arguments" {
1288 ); 1288 );
1289 try testing.expectEqual(@as(usize, 20), res.len); 1289 try testing.expectEqual(@as(usize, 20), res.len);
1290 1290
1291 for (res) |arg, i| { 1291 for (res, 0..) |arg, i| {
1292 try testing.expectEqualStrings("arg", arg.kv.key); 1292 try testing.expectEqualStrings("arg", arg.kv.key);
1293 try testing.expectEqual(i, try fmt.parseInt(usize, arg.kv.value, 10)); 1293 try testing.expectEqual(i, try fmt.parseInt(usize, arg.kv.value, 10));
1294 } 1294 }