summaryrefslogtreecommitdiff
path: root/src/duckdb/PreparedStatement.zig
diff options
context:
space:
mode:
authorEkaitz Zarraga <ekaitz@elenq.tech>2024-08-19 00:47:34 +0200
committerEkaitz Zarraga <ekaitz@elenq.tech>2024-08-19 00:47:34 +0200
commit7208d3e9ebc05591059f8244dee88bd91a73dee3 (patch)
treeb77a315a33ca1c693e695c210c86242b834d788f /src/duckdb/PreparedStatement.zig
parenta4227e7c8fbbe9c24443e269b459d367d59ef85a (diff)
PreparedStatement: work with stringsHEADmaster
Diffstat (limited to 'src/duckdb/PreparedStatement.zig')
-rw-r--r--src/duckdb/PreparedStatement.zig24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/duckdb/PreparedStatement.zig b/src/duckdb/PreparedStatement.zig
index 5e3229e..237152c 100644
--- a/src/duckdb/PreparedStatement.zig
+++ b/src/duckdb/PreparedStatement.zig
@@ -73,12 +73,14 @@ pub fn bindString(self: *Self, param: []const u8) !void{
self._current_binding += 1;
}
+
pub fn bind(self: *Self, param: anytype) !void {
switch (@typeInfo(@TypeOf(param))) {
.Null => return try self.bindNull(),
.Bool => return try self.bindBool(param),
.Int => return try self.bindInt(param),
.Float => return try self.bindFloat(param),
+ .Vector,
.Array => |arr| {
if (arr.child == u8){
return try self.bindString(param);
@@ -86,12 +88,22 @@ pub fn bind(self: *Self, param: anytype) !void {
return error.UnbindableType;
}
},
- .Pointer => |ptr| {
- if (ptr.size == .Slice and ptr.child == u8){
- return try self.bindString(param);
- } else {
- return error.UnbindableType;
- }
+ .Pointer => |info| switch (info.size) {
+ .One, .Many, .C, .Slice => switch (@typeInfo(info.child)) {
+ .Vector => |arr|
+ if (arr.child == u8){
+ return try self.bindString(param);
+ } else {
+ return error.UnbindableType;
+ },
+ .Array => |arr|
+ if (arr.child == u8){
+ return try self.bindString(param);
+ } else {
+ return error.UnbindableType;
+ },
+ else => {},
+ },
},
else => @compileError("Invalid type for binding: "
++ @typeName(@TypeOf(param))),