diff options
| author | 2021-01-02 00:40:58 +0100 | |
|---|---|---|
| committer | 2021-01-02 00:43:05 +0100 | |
| commit | 23d05ac87f2a90e63dea406f0dd7f33895bb0b64 (patch) | |
| tree | 1f10d86879b089ca04f94704a95e6631a050fa85 /sqlite.zig | |
| parent | allow binding a pointer (diff) | |
| download | zig-sqlite-23d05ac87f2a90e63dea406f0dd7f33895bb0b64.tar.gz zig-sqlite-23d05ac87f2a90e63dea406f0dd7f33895bb0b64.tar.xz zig-sqlite-23d05ac87f2a90e63dea406f0dd7f33895bb0b64.zip | |
stop special casing []const u8 and []u8, do it in the .Pointer switch arm
Diffstat (limited to 'sqlite.zig')
| -rw-r--r-- | sqlite.zig | 9 |
1 files changed, 6 insertions, 3 deletions
| @@ -722,9 +722,6 @@ pub fn Statement(comptime opts: StatementOptions, comptime query: ParsedQuery) t | |||
| 722 | const column = i + 1; | 722 | const column = i + 1; |
| 723 | 723 | ||
| 724 | switch (FieldType) { | 724 | switch (FieldType) { |
| 725 | []const u8, []u8 => { | ||
| 726 | _ = c.sqlite3_bind_text(self.stmt, column, field.ptr, @intCast(c_int, field.len), null); | ||
| 727 | }, | ||
| 728 | Text => _ = c.sqlite3_bind_text(self.stmt, column, field.data.ptr, @intCast(c_int, field.data.len), null), | 725 | Text => _ = c.sqlite3_bind_text(self.stmt, column, field.data.ptr, @intCast(c_int, field.data.len), null), |
| 729 | Blob => _ = c.sqlite3_bind_blob(self.stmt, column, field.data.ptr, @intCast(c_int, field.data.len), null), | 726 | Blob => _ = c.sqlite3_bind_blob(self.stmt, column, field.data.ptr, @intCast(c_int, field.data.len), null), |
| 730 | else => switch (field_type_info) { | 727 | else => switch (field_type_info) { |
| @@ -733,6 +730,12 @@ pub fn Statement(comptime opts: StatementOptions, comptime query: ParsedQuery) t | |||
| 733 | .Bool => _ = c.sqlite3_bind_int64(self.stmt, column, @boolToInt(field)), | 730 | .Bool => _ = c.sqlite3_bind_int64(self.stmt, column, @boolToInt(field)), |
| 734 | .Pointer => |ptr| switch (ptr.size) { | 731 | .Pointer => |ptr| switch (ptr.size) { |
| 735 | .One => self.bindField(ptr.child, field_name, i, field.*), | 732 | .One => self.bindField(ptr.child, field_name, i, field.*), |
| 733 | .Slice => switch (ptr.child) { | ||
| 734 | u8 => { | ||
| 735 | _ = c.sqlite3_bind_text(self.stmt, column, field.ptr, @intCast(c_int, field.len), null); | ||
| 736 | }, | ||
| 737 | else => @compileError("cannot bind field " ++ field_name ++ " of type " ++ @typeName(FieldType)), | ||
| 738 | }, | ||
| 736 | else => @compileError("cannot bind field " ++ field_name ++ " of type " ++ @typeName(FieldType)), | 739 | else => @compileError("cannot bind field " ++ field_name ++ " of type " ++ @typeName(FieldType)), |
| 737 | }, | 740 | }, |
| 738 | .Array => |arr| { | 741 | .Array => |arr| { |