Skip to content

Commit

Permalink
feat(generate):ignore field without ColumnName in template
Browse files Browse the repository at this point in the history
  • Loading branch information
tr1v3r committed Nov 9, 2021
1 parent b5d6331 commit 765a912
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions internal/template/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const (
_{{$.NewStructName}}.ALL = field.NewField(tableName, "*")
{{range .Members -}}
{{if not .IsRelation -}}
_{{$.NewStructName}}.{{.Name}} = field.New{{.GenType}}(tableName, "{{.ColumnName}}")
{{- if .ColumnName -}}_{{$.NewStructName}}.{{.Name}} = field.New{{.GenType}}(tableName, "{{.ColumnName}}"){{- end -}}
{{- else -}}
_{{$.NewStructName}}.{{.Relation.Name}} = {{$.NewStructName}}{{.Relation.RelationshipName}}{{.Relation.Name}}{
db: db.Session(&gorm.Session{}),
Expand All @@ -46,9 +46,9 @@ const (
_{{$.NewStructName}}.fieldMap = make(map[string]field.Expr, {{len .Members}})
{{range .Members -}}
{{if not .IsRelation -}}{{if .ColumnName -}}
_{{$.NewStructName}}.fieldMap["{{.ColumnName}}"] = _{{$.NewStructName}}.{{.Name}}
{{end -}}{{end -}}
{{if not .IsRelation -}}
{{- if .ColumnName -}}_{{$.NewStructName}}.fieldMap["{{.ColumnName}}"] = _{{$.NewStructName}}.{{.Name}}{{- end -}}
{{end}}
{{end}}
return _{{.NewStructName}}
}
Expand All @@ -58,7 +58,7 @@ const (
ALL field.Field
{{range .Members -}}
{{if not .IsRelation -}}
{{.Name}} field.{{.GenType}}
{{- if .ColumnName -}}{{.Name}} field.{{.GenType}}{{- end -}}
{{- else -}}
{{.Relation.Name}} {{$.NewStructName}}{{.Relation.RelationshipName}}{{.Relation.Name}}
{{end}}
Expand Down

0 comments on commit 765a912

Please sign in to comment.