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