Fix ommit empty db tag

This commit is contained in:
2025-03-05 22:03:32 +01:00
parent 904d4ce106
commit 7e9aab01cb

View File

@@ -55,6 +55,7 @@ func StructTagsToFields(s any) ([]DBField, error) {
useDefault := false
encrypted := false
ommit := false
if strings.Contains(tag, ",") {
parts := strings.Split(tag, ",")
@@ -64,7 +65,7 @@ func StructTagsToFields(s any) ([]DBField, error) {
switch opt {
case "omitempty":
if reflect.DeepEqual(v.Field(i).Interface(), reflect.Zero(f.Type).Interface()) {
continue
ommit = true
}
case "default":
useDefault = true
@@ -74,6 +75,10 @@ func StructTagsToFields(s any) ([]DBField, error) {
}
}
if ommit {
continue
}
fields = append(fields, DBField{
Name: tag,
Value: v.Field(i).Interface(),