mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-05 15:44:21 +00:00
Fix ommit empty db tag
This commit is contained in:
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user