RawFieldNames should ignore the field whose name is start with a dash (#2725)

This commit is contained in:
Archer
2022-12-24 21:27:32 +08:00
committed by GitHub
parent affbcb5698
commit 683d793719
2 changed files with 34 additions and 0 deletions

View File

@@ -45,9 +45,13 @@ func RawFieldNames(in interface{}, postgresSql ...bool) []string {
// `db:"id"`
// `db:"id,type=char,length=16"`
// `db:",type=char,length=16"`
// `db:"-,type=char,length=16"`
if strings.Contains(tagv, ",") {
tagv = strings.TrimSpace(strings.Split(tagv, ",")[0])
}
if tagv == "-" {
continue
}
if len(tagv) == 0 {
tagv = fi.Name
}