From 26c854a39c71b84139e71d55ba1010ee39ac35d1 Mon Sep 17 00:00:00 2001 From: Madeorsk Date: Thu, 17 Oct 2024 18:34:10 +0200 Subject: [PATCH] Fix ModelKeyType structure fields alignment. --- src/repository.zig | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/repository.zig b/src/repository.zig index 767fa59..47d9f9d 100644 --- a/src/repository.zig +++ b/src/repository.zig @@ -50,12 +50,15 @@ pub fn ModelKeyType(comptime Model: type, comptime TableShape: type, comptime co var fieldName: [keyName.len:0]u8 = undefined; @memcpy(fieldName[0..keyName.len], keyName); + // Get current field type. + const fieldType = std.meta.fields(TableShape)[std.meta.fieldIndex(TableShape, keyName).?].type; + field.* = .{ .name = &fieldName, - .type = std.meta.fields(TableShape)[std.meta.fieldIndex(TableShape, keyName).?].type, + .type = fieldType, .default_value = null, .is_comptime = false, - .alignment = 0, + .alignment = @alignOf(fieldType), }; }