Skip to content

Commit

Permalink
fix(generate): fix GetFieldByName panic
Browse files Browse the repository at this point in the history
  • Loading branch information
tr1v3r committed Dec 15, 2021
1 parent 14d5b60 commit 7ee5fc3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/template/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ func ({{.S}} {{.NewStructName}}) clone(db *gorm.DB) {{.NewStructName}} {
getFieldMethod = `
func ({{.S}} *{{.NewStructName}}) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := {{.S}}.fieldMap[fieldName]
return _f.(field.OrderExpr), ok
if !ok || _f == nil {
return nil, false
}
return _f.(field.OrderExpr), true
}
`
relationship = `{{range .Members}}{{if .IsRelation}}` +
Expand Down

0 comments on commit 7ee5fc3

Please sign in to comment.