summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sqlite.zig12
1 files changed, 6 insertions, 6 deletions
diff --git a/sqlite.zig b/sqlite.zig
index 111bb0a..4bd90c9 100644
--- a/sqlite.zig
+++ b/sqlite.zig
@@ -1073,7 +1073,7 @@ pub fn Iterator(comptime Type: type) type {
1073 1073
1074 if (@typeInfo(Type.BaseType) == .Int) { 1074 if (@typeInfo(Type.BaseType) == .Int) {
1075 const inner_value = try self.readField(Type.BaseType, options, 0); 1075 const inner_value = try self.readField(Type.BaseType, options, 0);
1076 return @intToEnum(Type, @intCast(TI.tag_type, inner_value)); 1076 return @enumFromInt(Type, @intCast(TI.tag_type, inner_value));
1077 } 1077 }
1078 1078
1079 @compileError("enum column " ++ @typeName(Type) ++ " must have a BaseType of either string or int"); 1079 @compileError("enum column " ++ @typeName(Type) ++ " must have a BaseType of either string or int");
@@ -1157,7 +1157,7 @@ pub fn Iterator(comptime Type: type) type {
1157 return std.meta.stringToEnum(Type, inner_value) orelse unreachable; 1157 return std.meta.stringToEnum(Type, inner_value) orelse unreachable;
1158 } 1158 }
1159 if (@typeInfo(Type.BaseType) == .Int) { 1159 if (@typeInfo(Type.BaseType) == .Int) {
1160 return @intToEnum(Type, @intCast(TI.tag_type, inner_value)); 1160 return @enumFromInt(Type, @intCast(TI.tag_type, inner_value));
1161 } 1161 }
1162 @compileError("enum column " ++ @typeName(Type) ++ " must have a BaseType of either string or int"); 1162 @compileError("enum column " ++ @typeName(Type) ++ " must have a BaseType of either string or int");
1163 }, 1163 },
@@ -1445,7 +1445,7 @@ pub fn Iterator(comptime Type: type) type {
1445 return std.meta.stringToEnum(FieldType, inner_value) orelse unreachable; 1445 return std.meta.stringToEnum(FieldType, inner_value) orelse unreachable;
1446 } 1446 }
1447 if (@typeInfo(FieldType.BaseType) == .Int) { 1447 if (@typeInfo(FieldType.BaseType) == .Int) {
1448 return @intToEnum(FieldType, @intCast(TI.tag_type, inner_value)); 1448 return @enumFromInt(FieldType, @intCast(TI.tag_type, inner_value));
1449 } 1449 }
1450 @compileError("enum column " ++ @typeName(FieldType) ++ " must have a BaseType of either string or int"); 1450 @compileError("enum column " ++ @typeName(FieldType) ++ " must have a BaseType of either string or int");
1451 }, 1451 },
@@ -1609,7 +1609,7 @@ pub const DynamicStatement = struct {
1609 return convertResultToError(result); 1609 return convertResultToError(result);
1610 }, 1610 },
1611 .Bool => { 1611 .Bool => {
1612 const result = c.sqlite3_bind_int64(self.stmt, column, @boolToInt(field)); 1612 const result = c.sqlite3_bind_int64(self.stmt, column, @intFromBool(field));
1613 return convertResultToError(result); 1613 return convertResultToError(result);
1614 }, 1614 },
1615 .Pointer => |ptr| switch (ptr.size) { 1615 .Pointer => |ptr| switch (ptr.size) {
@@ -1650,7 +1650,7 @@ pub const DynamicStatement = struct {
1650 if (comptime std.meta.trait.isZigString(FieldType.BaseType)) { 1650 if (comptime std.meta.trait.isZigString(FieldType.BaseType)) {
1651 try self.bindField(FieldType.BaseType, options, field_name, i, @tagName(field)); 1651 try self.bindField(FieldType.BaseType, options, field_name, i, @tagName(field));
1652 } else if (@typeInfo(FieldType.BaseType) == .Int) { 1652 } else if (@typeInfo(FieldType.BaseType) == .Int) {
1653 try self.bindField(FieldType.BaseType, options, field_name, i, @enumToInt(field)); 1653 try self.bindField(FieldType.BaseType, options, field_name, i, @intFromEnum(field));
1654 } else { 1654 } else {
1655 @compileError("enum column " ++ @typeName(FieldType) ++ " must have a BaseType of either string or int to bind"); 1655 @compileError("enum column " ++ @typeName(FieldType) ++ " must have a BaseType of either string or int to bind");
1656 } 1656 }
@@ -2969,7 +2969,7 @@ test "sqlite: statement iterator" {
2969 var i: usize = 0; 2969 var i: usize = 0;
2970 while (i < 20) : (i += 1) { 2970 while (i < 20) : (i += 1) {
2971 const name = try std.fmt.allocPrint(allocator, "Vincent {d}", .{i}); 2971 const name = try std.fmt.allocPrint(allocator, "Vincent {d}", .{i});
2972 const user = TestUser{ .id = i, .name = name, .age = i + 200, .weight = @intToFloat(f32, i + 200), .favorite_color = .indigo }; 2972 const user = TestUser{ .id = i, .name = name, .age = i + 200, .weight = @floatFromInt(f32, i + 200), .favorite_color = .indigo };
2973 2973
2974 try expected_rows.append(user); 2974 try expected_rows.append(user);
2975 2975