Răsfoiți Sursa

refactor: simplify the code (#1670)

Kevin Wan 3 ani în urmă
părinte
comite
f060a226bc
1 a modificat fișierele cu 10 adăugiri și 15 ștergeri
  1. 10 15
      core/stores/builder/builder.go

+ 10 - 15
core/stores/builder/builder.go

@@ -41,25 +41,20 @@ func RawFieldNames(in interface{}, postgresSql ...bool) []string {
 				out = append(out, fmt.Sprintf("`%s`", fi.Name))
 				out = append(out, fmt.Sprintf("`%s`", fi.Name))
 			}
 			}
 		default:
 		default:
-			//get tag name with the tag opton, e.g.:
-			//`db:"id"`
-			//`db:"id,type=char,length=16"`
-			//`db:",type=char,length=16"`
+			// get tag name with the tag opton, e.g.:
+			// `db:"id"`
+			// `db:"id,type=char,length=16"`
+			// `db:",type=char,length=16"`
 			if strings.Contains(tagv, ",") {
 			if strings.Contains(tagv, ",") {
 				tagv = strings.TrimSpace(strings.Split(tagv, ",")[0])
 				tagv = strings.TrimSpace(strings.Split(tagv, ",")[0])
 			}
 			}
-			if tagv != "" {
-				if pg {
-					out = append(out, tagv)
-				} else {
-					out = append(out, fmt.Sprintf("`%s`", tagv))
-				}
+			if len(tagv) == 0 {
+				tagv = fi.Name
+			}
+			if pg {
+				out = append(out, tagv)
 			} else {
 			} else {
-				if pg {
-					out = append(out, fi.Name)
-				} else {
-					out = append(out, fmt.Sprintf("`%s`", fi.Name))
-				}
+				out = append(out, fmt.Sprintf("`%s`", tagv))
 			}
 			}
 		}
 		}
 	}
 	}