diff options
Diffstat (limited to 'src/duckdb/PreparedStatement.zig')
-rw-r--r-- | src/duckdb/PreparedStatement.zig | 24 |
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))), |