summaryrefslogtreecommitdiff
path: root/sqlite.zig
diff options
context:
space:
mode:
authorGravatar Vincent Rischmann2025-01-06 22:32:11 +0100
committerGravatar GitHub2025-01-06 22:32:11 +0100
commit47a9c0d42ff5c083a9b04b04a5a1aeb0a777e153 (patch)
tree63a0fe1d11d393fa2db775b59836f9ce2b112b1d /sqlite.zig
parentbuild: the 'bundled' flag is useless (diff)
parentzig: remove workaround for ziglang#5149 (diff)
downloadzig-sqlite-47a9c0d42ff5c083a9b04b04a5a1aeb0a777e153.tar.gz
zig-sqlite-47a9c0d42ff5c083a9b04b04a5a1aeb0a777e153.tar.xz
zig-sqlite-47a9c0d42ff5c083a9b04b04a5a1aeb0a777e153.zip
Merge pull request #174 from rockorager/remove-workaround
zig: remove workaround for ziglang#5149
Diffstat (limited to 'sqlite.zig')
-rw-r--r--sqlite.zig24
1 files changed, 12 insertions, 12 deletions
diff --git a/sqlite.zig b/sqlite.zig
index 97ef60f..5f4b298 100644
--- a/sqlite.zig
+++ b/sqlite.zig
@@ -1070,15 +1070,15 @@ pub fn Iterator(comptime Type: type) type {
1070 switch (TypeInfo) { 1070 switch (TypeInfo) {
1071 .int => { 1071 .int => {
1072 debug.assert(columns == 1); 1072 debug.assert(columns == 1);
1073 return try self.readInt(Type, 0); 1073 return self.readInt(Type, 0);
1074 }, 1074 },
1075 .float => { 1075 .float => {
1076 debug.assert(columns == 1); 1076 debug.assert(columns == 1);
1077 return try self.readFloat(Type, 0); 1077 return self.readFloat(Type, 0);
1078 }, 1078 },
1079 .bool => { 1079 .bool => {
1080 debug.assert(columns == 1); 1080 debug.assert(columns == 1);
1081 return try self.readBool(0); 1081 return self.readBool(0);
1082 }, 1082 },
1083 .void => { 1083 .void => {
1084 debug.assert(columns == 1); 1084 debug.assert(columns == 1);
@@ -1144,15 +1144,15 @@ pub fn Iterator(comptime Type: type) type {
1144 switch (TypeInfo) { 1144 switch (TypeInfo) {
1145 .int => { 1145 .int => {
1146 debug.assert(columns == 1); 1146 debug.assert(columns == 1);
1147 return try self.readInt(Type, 0); 1147 return self.readInt(Type, 0);
1148 }, 1148 },
1149 .float => { 1149 .float => {
1150 debug.assert(columns == 1); 1150 debug.assert(columns == 1);
1151 return try self.readFloat(Type, 0); 1151 return self.readFloat(Type, 0);
1152 }, 1152 },
1153 .bool => { 1153 .bool => {
1154 debug.assert(columns == 1); 1154 debug.assert(columns == 1);
1155 return try self.readBool(0); 1155 return self.readBool(0);
1156 }, 1156 },
1157 .void => { 1157 .void => {
1158 debug.assert(columns == 1); 1158 debug.assert(columns == 1);
@@ -1242,19 +1242,19 @@ pub fn Iterator(comptime Type: type) type {
1242 } 1242 }
1243 1243
1244 // readInt reads a sqlite INTEGER column into an integer. 1244 // readInt reads a sqlite INTEGER column into an integer.
1245 fn readInt(self: *Self, comptime IntType: type, i: usize) error{Workaround}!IntType { // TODO remove the workaround once https://github.com/ziglang/zig/issues/5149 is resolved or if we actually return an error 1245 fn readInt(self: *Self, comptime IntType: type, i: usize) IntType {
1246 const n = c.sqlite3_column_int64(self.stmt, @intCast(i)); 1246 const n = c.sqlite3_column_int64(self.stmt, @intCast(i));
1247 return @intCast(n); 1247 return @intCast(n);
1248 } 1248 }
1249 1249
1250 // readFloat reads a sqlite REAL column into a float. 1250 // readFloat reads a sqlite REAL column into a float.
1251 fn readFloat(self: *Self, comptime FloatType: type, i: usize) error{Workaround}!FloatType { // TODO remove the workaround once https://github.com/ziglang/zig/issues/5149 is resolved or if we actually return an error 1251 fn readFloat(self: *Self, comptime FloatType: type, i: usize) FloatType {
1252 const d = c.sqlite3_column_double(self.stmt, @intCast(i)); 1252 const d = c.sqlite3_column_double(self.stmt, @intCast(i));
1253 return @floatCast(d); 1253 return @floatCast(d);
1254 } 1254 }
1255 1255
1256 // readFloat reads a sqlite INTEGER column into a bool (true is anything > 0, false is anything <= 0). 1256 // readFloat reads a sqlite INTEGER column into a bool (true is anything > 0, false is anything <= 0).
1257 fn readBool(self: *Self, i: usize) error{Workaround}!bool { // TODO remove the workaround once https://github.com/ziglang/zig/issues/5149 is resolved or if we actually return an error 1257 fn readBool(self: *Self, i: usize) bool {
1258 const d = c.sqlite3_column_int64(self.stmt, @intCast(i)); 1258 const d = c.sqlite3_column_int64(self.stmt, @intCast(i));
1259 return d > 0; 1259 return d > 0;
1260 } 1260 }
@@ -1450,9 +1450,9 @@ pub fn Iterator(comptime Type: type) type {
1450 break :blk try self.readBytes(Text, options.allocator, i, .Text); 1450 break :blk try self.readBytes(Text, options.allocator, i, .Text);
1451 }, 1451 },
1452 else => switch (field_type_info) { 1452 else => switch (field_type_info) {
1453 .int => try self.readInt(FieldType, i), 1453 .int => self.readInt(FieldType, i),
1454 .float => try self.readFloat(FieldType, i), 1454 .float => self.readFloat(FieldType, i),
1455 .bool => try self.readBool(i), 1455 .bool => self.readBool(i),
1456 .void => {}, 1456 .void => {},
1457 .array => try self.readArray(FieldType, i), 1457 .array => try self.readArray(FieldType, i),
1458 .pointer => try self.readPointer(FieldType, options, i), 1458 .pointer => try self.readPointer(FieldType, options, i),