diff options
| author | 2021-09-23 22:13:47 -0700 | |
|---|---|---|
| committer | 2021-09-23 22:13:47 -0700 | |
| commit | 05c09deea008b0b36318200721bc677acf909a55 (patch) | |
| tree | 64f6d3424acb2b1b7b8923fee8a7a2c923b54f9b /sqlite.zig | |
| parent | add iteratorAlloc and execAlloc (diff) | |
| download | zig-sqlite-05c09deea008b0b36318200721bc677acf909a55.tar.gz zig-sqlite-05c09deea008b0b36318200721bc677acf909a55.tar.xz zig-sqlite-05c09deea008b0b36318200721bc677acf909a55.zip | |
add BaseType support for structs
Diffstat (limited to '')
| -rw-r--r-- | sqlite.zig | 7 |
1 files changed, 7 insertions, 0 deletions
| @@ -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 | } |