chore: refactor code (#1613)

This commit is contained in:
Kevin Wan
2022-03-04 17:55:13 +08:00
committed by GitHub
parent 3b7ca86e4f
commit b939ce75ba

View File

@@ -31,21 +31,21 @@ func RawFieldNames(in interface{}, postgresSql ...bool) []string {
// gets us a StructField // gets us a StructField
fi := typ.Field(i) fi := typ.Field(i)
tagv := fi.Tag.Get(dbTag) tagv := fi.Tag.Get(dbTag)
switch { switch tagv {
case tagv == "-": case "-":
continue continue
case tagv != "": case "":
if pg {
out = append(out, tagv)
} else {
out = append(out, fmt.Sprintf("`%s`", tagv))
}
default:
if pg { if pg {
out = append(out, fi.Name) out = append(out, fi.Name)
} else { } else {
out = append(out, fmt.Sprintf("`%s`", fi.Name)) out = append(out, fmt.Sprintf("`%s`", fi.Name))
} }
default:
if pg {
out = append(out, tagv)
} else {
out = append(out, fmt.Sprintf("`%s`", tagv))
}
} }
} }