8000 bugfix: fixed broken client.go generation when last node is a view by marcobeierer · Pull Request #4224 · ent/ent · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

bugfix: fixed broken client.go generation when last node is a view #4224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions entc/gen/template/client.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -481,17 +481,25 @@ func (c *{{ $client }}) mutate(ctx context.Context, m *{{ $n.MutationName }}) (V
// hooks and interceptors per client, for fast access.
type (
{{- $leni := len $.Nodes | add -1 }}
{{- $hooks := slist }}
{{- $hookNodes := list }}
{{- $inters := slist }}
{{- range $i, $n := $.Nodes }}
{{ if not $n.IsView }}{{- $hookNodes = append $hookNodes $n }}{{ end }}
{{- if eq $i $leni }}
{{ if not $n.IsView }}{{- $hooks = append $hooks (printf "%s []ent.Hook" $n.Name) }}{{ end }}
{{- $inters = append $inters (printf "%s []ent.Interceptor" $n.Name) }}
{{- else }}
{{ if not $n.IsView }}{{- $hooks = append $hooks (print $n.Name ",") }}{{ end }}
{{- $inters = append $inters (print $n.Name ",") }}
{{- end }}
{{- end }}
{{- $leni = len $hookNodes | add -1 }}
{{- $hooks := slist }}
{{- range $i, $n := $hookNodes }}
{{- if eq $i $leni }}
{{- $hooks = append $hooks (printf "%s []ent.Hook" $n.Name) }}
{{- else }}
{{- $hooks = append $hooks (printf "%s," $n.Name) }}
{{- end }}
{{- end }}
hooks struct {
{{ joinWords $hooks 80 }}
}
Expand Down
2 changes: 1 addition & 1 deletion entc/integration/hooks/ent/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0