summaryrefslogtreecommitdiff
path: root/sqlite.zig
diff options
context:
space:
mode:
authorGravatar Meghan Denny2021-09-23 22:13:47 -0700
committerGravatar Meghan Denny2021-09-23 22:13:47 -0700
commit05c09deea008b0b36318200721bc677acf909a55 (patch)
tree64f6d3424acb2b1b7b8923fee8a7a2c923b54f9b /sqlite.zig
parentadd iteratorAlloc and execAlloc (diff)
downloadzig-sqlite-05c09deea008b0b36318200721bc677acf909a55.tar.gz
zig-sqlite-05c09deea008b0b36318200721bc677acf909a55.tar.xz
zig-sqlite-05c09deea008b0b36318200721bc677acf909a55.zip
add BaseType support for structs
Diffstat (limited to 'sqlite.zig')
-rw-r--r--sqlite.zig7
1 files changed, 7 insertions, 0 deletions
diff --git a/sqlite.zig b/sqlite.zig
index 2ddb3f7..8662262 100644
--- a/sqlite.zig
+++ b/sqlite.zig
@@ -981,6 +981,10 @@ pub fn Iterator(comptime Type: type) type {
981 } 981 }
982 @compileError("enum column " ++ @typeName(FieldType) ++ " must have a BaseType of either string or int"); 982 @compileError("enum column " ++ @typeName(FieldType) ++ " must have a BaseType of either string or int");
983 }, 983 },
984 .Struct => {
985 const innervalue = try self.readField(FieldType.BaseType, options, i);
986 return try FieldType.readField(options.allocator, innervalue);
987 },
984 else => @compileError("cannot populate field of type " ++ @typeName(FieldType)), 988 else => @compileError("cannot populate field of type " ++ @typeName(FieldType)),
985 }, 989 },
986 }; 990 };
@@ -1186,6 +1190,9 @@ pub fn Statement(comptime opts: StatementOptions, comptime query: ParsedQuery) t
1186 } 1190 }
1187 @compileError("enum column " ++ @typeName(FieldType) ++ " must have a BaseType of either string or int to bind"); 1191 @compileError("enum column " ++ @typeName(FieldType) ++ " must have a BaseType of either string or int to bind");
1188 }, 1192 },
1193 .Struct => {
1194 return try self.bindField(FieldType.BaseType, options, field_name, i, try field.bindField(options.allocator));
1195 },
1189 else => @compileError("cannot bind field " ++ field_name ++ " of type " ++ @typeName(FieldType)), 1196 else => @compileError("cannot bind field " ++ field_name ++ " of type " ++ @typeName(FieldType)),
1190 }, 1197 },
1191 } 1198 }