summaryrefslogtreecommitdiff
path: root/src/duckdb
diff options
context:
space:
mode:
authorEkaitz Zarraga <ekaitz@elenq.tech>2024-08-01 16:41:07 +0200
committerEkaitz Zarraga <ekaitz@elenq.tech>2024-08-01 16:41:07 +0200
commita86a078a9707bdc3b0bd7ce9c8d72a89c8c942b4 (patch)
treefb159f93ecf8fbd0fbe27042d0ee8f09f093113d /src/duckdb
parentb5316c4dc3ba84a4257b996f9d1505f95fe95ab4 (diff)
Start generic type matching
Diffstat (limited to 'src/duckdb')
-rw-r--r--src/duckdb/Result.zig21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/duckdb/Result.zig b/src/duckdb/Result.zig
index b49f704..2b5b992 100644
--- a/src/duckdb/Result.zig
+++ b/src/duckdb/Result.zig
@@ -22,6 +22,21 @@ pub fn Result(comptime T: type) type{
return error.DuckDBError;
}
self.fetchDataChunk();
+
+ // Get column vectors
+ switch (@typeInfo(T)) {
+ .Struct => |v| {
+ const column_count = v.fields.len;
+ var columns : [column_count]c.duckdb_vector = undefined;
+ for (columns, 0..) |_, i| {
+ columns[i] = c.duckdb_data_chunk_get_vector(self._chunk, i);
+ }
+ std.debug.print("{any}", .{columns});
+ },
+ .Void => {},
+ else => @compileError("Expecting struct or void in query result type"),
+ }
+
return self;
}
pub fn deinit(self: *Self) void {
@@ -59,12 +74,8 @@ pub fn Result(comptime T: type) type{
/// We need some comptime magic to create the output structures from
/// the T.
pub fn next(self: *Self) T{
- _ = self;
const result: T = undefined;
- switch (@typeInfo(T)) {
- .Struct => std.debug.print("GOOOD: ", .{}),
- else => null,
- }
+ _ = self;
return result;
}
};