Skip to content

Commit

Permalink
model中db标签增加'-'符号以支持数据库查询时忽略对应字段. (zeromicro#1612)
Browse files Browse the repository at this point in the history
  • Loading branch information
l306287405 authored Mar 4, 2022
1 parent 96c128c commit 60760b5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions core/stores/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,17 @@ func RawFieldNames(in interface{}, postgresSql ...bool) []string {
for i := 0; i < v.NumField(); i++ {
// gets us a StructField
fi := typ.Field(i)
if tagv := fi.Tag.Get(dbTag); tagv != "" {
tagv := fi.Tag.Get(dbTag)
switch {
case tagv == "-":
continue
case tagv != "":
if pg {
out = append(out, tagv)
} else {
out = append(out, fmt.Sprintf("`%s`", tagv))
}
} else {
default:
if pg {
out = append(out, fi.Name)
} else {
Expand Down

0 comments on commit 60760b5

Please sign in to comment.