Skip to content

Commit

Permalink
entgql: improve var name collision avoidance in toCursor (#572)
Browse files Browse the repository at this point in the history
Improves variable name collision avoidance in the `toCursor` method of
the pager types in the `gql_pagination` template by suffixing all
hard-coded variables names with an underscore.
  • Loading branch information
henrywoody authored Apr 11, 2024
1 parent 439e519 commit 4ec1976
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 48 deletions.
24 changes: 12 additions & 12 deletions entgql/internal/todo/ent/gql_pagination.go

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

16 changes: 8 additions & 8 deletions entgql/internal/todogotype/ent/gql_pagination.go

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

24 changes: 12 additions & 12 deletions entgql/internal/todopulid/ent/gql_pagination.go

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

24 changes: 12 additions & 12 deletions entgql/internal/todouuid/ent/gql_pagination.go

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

8 changes: 4 additions & 4 deletions entgql/template/pagination.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,12 @@ func (p *{{ $pager }}) applyFilter(query *{{ $query }}) (*{{ $query }}, error) {
{{ $r := $node.Receiver }}
func (p *{{ $pager }}) toCursor({{ $r }} *{{ $name }}) Cursor {
{{- if $multiOrder }}
cs := make([]any, 0, len(p.order))
for _, po := range p.order {
cs = append(cs, po.Field.toCursor({{ $r }}).Value)
cs_ := make([]any, 0, len(p.order))
for _, o_ := range p.order {
cs_ = append(cs_, o_.Field.toCursor({{ $r }}).Value)
}
{{- $marshalID := and $idType.Mixed (gqlMarshaler $node.ID) }}
return Cursor{ID: {{ $r }}.{{ if $marshalID }}marshalID(){{ else }}ID{{ end }}, Value: cs}
return Cursor{ID: {{ $r }}.{{ if $marshalID }}marshalID(){{ else }}ID{{ end }}, Value: cs_}
{{- else }}
return p.order.Field.toCursor({{ $r }})
{{- end }}
Expand Down

0 comments on commit 4ec1976

Please sign in to comment.