diff options
| -rw-r--r-- | sqlite.zig | 25 |
1 files changed, 11 insertions, 14 deletions
| @@ -1053,20 +1053,11 @@ pub fn Statement(comptime opts: StatementOptions, comptime query: ParsedQuery) t | |||
| 1053 | .Typed => |typ| { | 1053 | .Typed => |typ| { |
| 1054 | const FieldTypeInfo = @typeInfo(struct_field.field_type); | 1054 | const FieldTypeInfo = @typeInfo(struct_field.field_type); |
| 1055 | switch (FieldTypeInfo) { | 1055 | switch (FieldTypeInfo) { |
| 1056 | .Struct, .Enum, .Union => { | 1056 | .Struct, .Enum, .Union => comptime assertMarkerType( |
| 1057 | if (@hasDecl(struct_field.field_type, "BaseType")) { | 1057 | if (@hasDecl(struct_field.field_type, "BaseType")) struct_field.field_type.BaseType else struct_field.field_type, |
| 1058 | if (struct_field.field_type.BaseType != typ) { | 1058 | typ, |
| 1059 | @compileError("value type " ++ @typeName(struct_field.field_type.BaseType) ++ " is not the bind marker type " ++ @typeName(typ)); | 1059 | ), |
| 1060 | } | 1060 | else => comptime assertMarkerType(struct_field.field_type, typ), |
| 1061 | } else if (struct_field.field_type != typ) { | ||
| 1062 | @compileError("value type " ++ @typeName(struct_field.field_type) ++ " is not the bind marker type " ++ @typeName(typ)); | ||
| 1063 | } | ||
| 1064 | }, | ||
| 1065 | else => { | ||
| 1066 | if (struct_field.field_type != typ) { | ||
| 1067 | @compileError("value type " ++ @typeName(struct_field.field_type) ++ " is not the bind marker type " ++ @typeName(typ)); | ||
| 1068 | } | ||
| 1069 | }, | ||
| 1070 | } | 1061 | } |
| 1071 | }, | 1062 | }, |
| 1072 | .Untyped => {}, | 1063 | .Untyped => {}, |
| @@ -1078,6 +1069,12 @@ pub fn Statement(comptime opts: StatementOptions, comptime query: ParsedQuery) t | |||
| 1078 | } | 1069 | } |
| 1079 | } | 1070 | } |
| 1080 | 1071 | ||
| 1072 | fn assertMarkerType(comptime Actual: type, comptime Expected: type) void { | ||
| 1073 | if (Actual != Expected) { | ||
| 1074 | @compileError("value type " ++ @typeName(Actual) ++ " is not the bind marker type " ++ @typeName(Expected)); | ||
| 1075 | } | ||
| 1076 | } | ||
| 1077 | |||
| 1081 | fn bindField(self: *Self, comptime FieldType: type, comptime field_name: []const u8, i: c_int, field: FieldType) void { | 1078 | fn bindField(self: *Self, comptime FieldType: type, comptime field_name: []const u8, i: c_int, field: FieldType) void { |
| 1082 | const field_type_info = @typeInfo(FieldType); | 1079 | const field_type_info = @typeInfo(FieldType); |
| 1083 | const column = i + 1; | 1080 | const column = i + 1; |