summaryrefslogtreecommitdiff
path: root/sqlite.zig
diff options
context:
space:
mode:
authorGravatar Vincent Rischmann2024-04-14 18:10:28 +0200
committerGravatar Vincent Rischmann2024-04-14 18:10:28 +0200
commit49db791a43fdf4afecc27336d84ca6ab780b7f77 (patch)
tree32caf521bef501420e75ace3939d4aa47f827bdc /sqlite.zig
parentMerge pull request #154 from JacobCrabill/dev/zig-0.12-modules (diff)
downloadzig-sqlite-49db791a43fdf4afecc27336d84ca6ab780b7f77.tar.gz
zig-sqlite-49db791a43fdf4afecc27336d84ca6ab780b7f77.tar.xz
zig-sqlite-49db791a43fdf4afecc27336d84ca6ab780b7f77.zip
fix for latest zig
Also some major refactoring around the query parsing state.
Diffstat (limited to 'sqlite.zig')
-rw-r--r--sqlite.zig15
1 files changed, 9 insertions, 6 deletions
diff --git a/sqlite.zig b/sqlite.zig
index e19f83b..be46dea 100644
--- a/sqlite.zig
+++ b/sqlite.zig
@@ -1491,7 +1491,7 @@ pub fn Iterator(comptime Type: type) type {
1491 @compileError("enum column " ++ @typeName(FieldType) ++ " must have a BaseType of either string or int"); 1491 @compileError("enum column " ++ @typeName(FieldType) ++ " must have a BaseType of either string or int");
1492 }, 1492 },
1493 .Struct => |TI| { 1493 .Struct => |TI| {
1494 if (TI.layout == .Packed) return @bitCast(try self.readInt(TI.backing_integer.?, i)); 1494 if (TI.layout == .@"packed") return @bitCast(try self.readInt(TI.backing_integer.?, i));
1495 const inner_value = try self.readField(FieldType.BaseType, options, i); 1495 const inner_value = try self.readField(FieldType.BaseType, options, i);
1496 return try FieldType.readField(options.allocator, inner_value); 1496 return try FieldType.readField(options.allocator, inner_value);
1497 }, 1497 },
@@ -1512,8 +1512,11 @@ pub fn Iterator(comptime Type: type) type {
1512/// }; 1512/// };
1513/// 1513///
1514pub fn StatementType(comptime opts: StatementOptions, comptime query: []const u8) type { 1514pub fn StatementType(comptime opts: StatementOptions, comptime query: []const u8) type {
1515 @setEvalBranchQuota(100000); 1515 comptime {
1516 return Statement(opts, ParsedQuery(query)); 1516 @setEvalBranchQuota(100000);
1517 const parsed_query = ParsedQuery(query);
1518 return Statement(opts, parsed_query);
1519 }
1517} 1520}
1518 1521
1519pub const StatementOptions = struct {}; 1522pub const StatementOptions = struct {};
@@ -1698,7 +1701,7 @@ pub const DynamicStatement = struct {
1698 } 1701 }
1699 }, 1702 },
1700 .Struct => |info| { 1703 .Struct => |info| {
1701 if (info.layout == .Packed) { 1704 if (info.layout == .@"packed") {
1702 try self.bindField(info.backing_integer.?, options, field_name, i, @as(info.backing_integer.?, @bitCast(field))); 1705 try self.bindField(info.backing_integer.?, options, field_name, i, @as(info.backing_integer.?, @bitCast(field)));
1703 return; 1706 return;
1704 } 1707 }
@@ -2066,9 +2069,9 @@ pub fn Statement(comptime opts: StatementOptions, comptime query: anytype) type
2066 2069
2067 const StructTypeInfo = @typeInfo(StructType).Struct; 2070 const StructTypeInfo = @typeInfo(StructType).Struct;
2068 2071
2069 if (comptime query.nb_bind_markers != StructTypeInfo.fields.len) { 2072 if (comptime query.bind_markers.len != StructTypeInfo.fields.len) {
2070 @compileError(std.fmt.comptimePrint("expected {d} bind parameters but got {d}", .{ 2073 @compileError(std.fmt.comptimePrint("expected {d} bind parameters but got {d}", .{
2071 query.nb_bind_markers, 2074 query.bind_markers.len,
2072 StructTypeInfo.fields.len, 2075 StructTypeInfo.fields.len,
2073 })); 2076 }));
2074 } 2077 }