Fix ModelKeyType structure fields alignment.

This commit is contained in:
Madeorsk 2024-10-17 18:34:10 +02:00
parent 28bef7ef42
commit 26c854a39c
Signed by: Madeorsk
GPG key ID: 677E51CA765BB79F

View file

@ -50,12 +50,15 @@ pub fn ModelKeyType(comptime Model: type, comptime TableShape: type, comptime co
var fieldName: [keyName.len:0]u8 = undefined; var fieldName: [keyName.len:0]u8 = undefined;
@memcpy(fieldName[0..keyName.len], keyName); @memcpy(fieldName[0..keyName.len], keyName);
// Get current field type.
const fieldType = std.meta.fields(TableShape)[std.meta.fieldIndex(TableShape, keyName).?].type;
field.* = .{ field.* = .{
.name = &fieldName, .name = &fieldName,
.type = std.meta.fields(TableShape)[std.meta.fieldIndex(TableShape, keyName).?].type, .type = fieldType,
.default_value = null, .default_value = null,
.is_comptime = false, .is_comptime = false,
.alignment = 0, .alignment = @alignOf(fieldType),
}; };
} }