diff options
| -rw-r--r-- | sqlite.zig | 12 |
1 files changed, 9 insertions, 3 deletions
| @@ -667,19 +667,25 @@ pub fn Iterator(comptime Type: type) type { | |||
| 667 | } | 667 | } |
| 668 | 668 | ||
| 669 | // readInt reads a sqlite INTEGER column into an integer. | 669 | // readInt reads a sqlite INTEGER column into an integer. |
| 670 | fn readInt(self: *Self, comptime IntType: type, i: usize) !IntType { | 670 | // |
| 671 | // TODO remove the workaround once https://github.com/ziglang/zig/issues/5149 is resolved or if we actually return an error | ||
| 672 | fn readInt(self: *Self, comptime IntType: type, i: usize) error{Workaround}!IntType { | ||
| 671 | const n = c.sqlite3_column_int64(self.stmt, @intCast(c_int, i)); | 673 | const n = c.sqlite3_column_int64(self.stmt, @intCast(c_int, i)); |
| 672 | return @intCast(IntType, n); | 674 | return @intCast(IntType, n); |
| 673 | } | 675 | } |
| 674 | 676 | ||
| 675 | // readFloat reads a sqlite REAL column into a float. | 677 | // readFloat reads a sqlite REAL column into a float. |
| 676 | fn readFloat(self: *Self, comptime FloatType: type, i: usize) !FloatType { | 678 | // |
| 679 | // TODO remove the workaround once https://github.com/ziglang/zig/issues/5149 is resolved or if we actually return an error | ||
| 680 | fn readFloat(self: *Self, comptime FloatType: type, i: usize) error{Workaround}!FloatType { | ||
| 677 | const d = c.sqlite3_column_double(self.stmt, @intCast(c_int, i)); | 681 | const d = c.sqlite3_column_double(self.stmt, @intCast(c_int, i)); |
| 678 | return @floatCast(FloatType, d); | 682 | return @floatCast(FloatType, d); |
| 679 | } | 683 | } |
| 680 | 684 | ||
| 681 | // readFloat reads a sqlite INTEGER column into a bool (true is anything > 0, false is anything <= 0). | 685 | // readFloat reads a sqlite INTEGER column into a bool (true is anything > 0, false is anything <= 0). |
| 682 | fn readBool(self: *Self, i: usize) !bool { | 686 | // |
| 687 | // TODO remove the workaround once https://github.com/ziglang/zig/issues/5149 is resolved or if we actually return an error | ||
| 688 | fn readBool(self: *Self, i: usize) error{Workaround}!bool { | ||
| 683 | const d = c.sqlite3_column_int64(self.stmt, @intCast(c_int, i)); | 689 | const d = c.sqlite3_column_int64(self.stmt, @intCast(c_int, i)); |
| 684 | return d > 0; | 690 | return d > 0; |
| 685 | } | 691 | } |