summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sqlite.zig20
1 files changed, 18 insertions, 2 deletions
diff --git a/sqlite.zig b/sqlite.zig
index a72a143..67b67f5 100644
--- a/sqlite.zig
+++ b/sqlite.zig
@@ -1050,8 +1050,24 @@ pub fn Statement(comptime opts: StatementOptions, comptime query: ParsedQuery) t
1050 inline for (StructTypeInfo.fields) |struct_field, _i| { 1050 inline for (StructTypeInfo.fields) |struct_field, _i| {
1051 const bind_marker = query.bind_markers[_i]; 1051 const bind_marker = query.bind_markers[_i];
1052 switch (bind_marker) { 1052 switch (bind_marker) {
1053 .Typed => |typ| if (struct_field.field_type != typ and struct_field.field_type.BaseType != typ) { 1053 .Typed => |typ| {
1054 @compileError("value type " ++ @typeName(struct_field.field_type) ++ " is not the bind marker type " ++ @typeName(typ)); 1054 const FieldTypeInfo = @typeInfo(struct_field.field_type);
1055 switch (FieldTypeInfo) {
1056 .Struct, .Enum, .Union => {
1057 if (@hasDecl(struct_field.field_type, "BaseType")) {
1058 if (struct_field.field_type.BaseType != typ) {
1059 @compileError("value type " ++ @typeName(struct_field.field_type.BaseType) ++ " is not the bind marker type " ++ @typeName(typ));
1060 }
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 }
1055 }, 1071 },
1056 .Untyped => {}, 1072 .Untyped => {},
1057 } 1073 }