From b939ce75ba7f5404fcf4964e6e7cb7ba9a23e6ab Mon Sep 17 00:00:00 2001 From: Kevin Wan Date: Fri, 4 Mar 2022 17:55:13 +0800 Subject: [PATCH] chore: refactor code (#1613) --- core/stores/builder/builder.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/core/stores/builder/builder.go b/core/stores/builder/builder.go index 8c731ae5..cddd1298 100644 --- a/core/stores/builder/builder.go +++ b/core/stores/builder/builder.go @@ -31,20 +31,20 @@ func RawFieldNames(in interface{}, postgresSql ...bool) []string { // gets us a StructField fi := typ.Field(i) tagv := fi.Tag.Get(dbTag) - switch { - case tagv == "-": + switch tagv { + case "-": continue - case tagv != "": + case "": if pg { - out = append(out, tagv) + out = append(out, fi.Name) } else { - out = append(out, fmt.Sprintf("`%s`", tagv)) + out = append(out, fmt.Sprintf("`%s`", fi.Name)) } default: if pg { - out = append(out, fi.Name) + out = append(out, tagv) } else { - out = append(out, fmt.Sprintf("`%s`", fi.Name)) + out = append(out, fmt.Sprintf("`%s`", tagv)) } } }