model中db标签增加'-'符号以支持数据库查询时忽略对应字段. (#1612)
This commit is contained in:
@@ -30,13 +30,17 @@ func RawFieldNames(in interface{}, postgresSql ...bool) []string {
|
|||||||
for i := 0; i < v.NumField(); i++ {
|
for i := 0; i < v.NumField(); i++ {
|
||||||
// gets us a StructField
|
// gets us a StructField
|
||||||
fi := typ.Field(i)
|
fi := typ.Field(i)
|
||||||
if tagv := fi.Tag.Get(dbTag); tagv != "" {
|
tagv := fi.Tag.Get(dbTag)
|
||||||
|
switch {
|
||||||
|
case tagv == "-":
|
||||||
|
continue
|
||||||
|
case tagv != "":
|
||||||
if pg {
|
if pg {
|
||||||
out = append(out, tagv)
|
out = append(out, tagv)
|
||||||
} else {
|
} else {
|
||||||
out = append(out, fmt.Sprintf("`%s`", tagv))
|
out = append(out, fmt.Sprintf("`%s`", tagv))
|
||||||
}
|
}
|
||||||
} else {
|
default:
|
||||||
if pg {
|
if pg {
|
||||||
out = append(out, fi.Name)
|
out = append(out, fi.Name)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user