Skip to content

Commit 4ec1976

Browse files
authored
entgql: improve var name collision avoidance in toCursor (#572)
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.
1 parent 439e519 commit 4ec1976

File tree

5 files changed

+48
-48
lines changed

5 files changed

+48
-48
lines changed

entgql/internal/todo/ent/gql_pagination.go

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

entgql/internal/todogotype/ent/gql_pagination.go

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

entgql/internal/todopulid/ent/gql_pagination.go

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

entgql/internal/todouuid/ent/gql_pagination.go

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

entgql/template/pagination.tmpl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,12 +271,12 @@ func (p *{{ $pager }}) applyFilter(query *{{ $query }}) (*{{ $query }}, error) {
271271
{{ $r := $node.Receiver }}
272272
func (p *{{ $pager }}) toCursor({{ $r }} *{{ $name }}) Cursor {
273273
{{- if $multiOrder }}
274-
cs := make([]any, 0, len(p.order))
275-
for _, po := range p.order {
276-
cs = append(cs, po.Field.toCursor({{ $r }}).Value)
274+
cs_ := make([]any, 0, len(p.order))
275+
for _, o_ := range p.order {
276+
cs_ = append(cs_, o_.Field.toCursor({{ $r }}).Value)
277277
}
278278
{{- $marshalID := and $idType.Mixed (gqlMarshaler $node.ID) }}
279-
return Cursor{ID: {{ $r }}.{{ if $marshalID }}marshalID(){{ else }}ID{{ end }}, Value: cs}
279+
return Cursor{ID: {{ $r }}.{{ if $marshalID }}marshalID(){{ else }}ID{{ end }}, Value: cs_}
280280
{{- else }}
281281
return p.order.Field.toCursor({{ $r }})
282282
{{- end }}

0 commit comments

Comments
 (0)