From 05c09deea008b0b36318200721bc677acf909a55 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Thu, 23 Sep 2021 22:13:47 -0700 Subject: add BaseType support for structs --- sqlite.zig | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'sqlite.zig') 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 { } @compileError("enum column " ++ @typeName(FieldType) ++ " must have a BaseType of either string or int"); }, + .Struct => { + const innervalue = try self.readField(FieldType.BaseType, options, i); + return try FieldType.readField(options.allocator, innervalue); + }, else => @compileError("cannot populate field of type " ++ @typeName(FieldType)), }, }; @@ -1186,6 +1190,9 @@ pub fn Statement(comptime opts: StatementOptions, comptime query: ParsedQuery) t } @compileError("enum column " ++ @typeName(FieldType) ++ " must have a BaseType of either string or int to bind"); }, + .Struct => { + return try self.bindField(FieldType.BaseType, options, field_name, i, try field.bindField(options.allocator)); + }, else => @compileError("cannot bind field " ++ field_name ++ " of type " ++ @typeName(FieldType)), }, } -- cgit v1.2.3