Skip to content

Commit

Permalink
entgql: avoid naming conflicts in toCursor template (#538)
Browse files Browse the repository at this point in the history
* fix: rename variable when iterating through p.order to prevent conflict with $r that starts with "O" character

* fix: run go generate on entgql
  • Loading branch information
Tantatorn-dev authored Jul 25, 2023
1 parent 02db1ac commit 9e1dadf
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
12 changes: 6 additions & 6 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.

8 changes: 4 additions & 4 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.

12 changes: 6 additions & 6 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.

12 changes: 6 additions & 6 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.

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

0 comments on commit 9e1dadf

Please sign in to comment.