Skip to content

Commit

Permalink
bug: fix incorrect field name singularize (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyCherenkov authored Feb 4, 2025
1 parent 428d4c4 commit 99d5e3e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion templates/create.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ import (
{{- end }}
{{- else }}
{{- if not $e.Unique }}
builder.Add{{ $e.StructField|zsingular }}IDs(c.{{ $e.StructField }}...)
builder.Add{{ $e.Name|zsingular|pascal }}IDs(c.{{ $e.StructField }}...)
{{- else if $e.Optional }}
if c.{{ $e.StructField }} != nil {
builder.Set{{ $e.StructField }}ID(*c.{{ $e.StructField }})
Expand Down
4 changes: 2 additions & 2 deletions templates/update.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,15 @@ import (
{{- if not $e.Unique }}
{{- range $prefix := list "Add" "Remove" }}
if v, ok := u.{{ $prefix }}{{ $e.StructField }}.Get(); ok && v != nil {
builder.{{ $prefix }}{{ $e.StructField|singular }}IDs(v...)
builder.{{ $prefix }}{{ $e.Name|singular|pascal }}IDs(v...)
}
{{- end }}
{{- if $e.Annotations.Rest.EdgeUpdateBulk }}
// If add_<edge> or remove_<edge> is provided, don't clear or use this field.
if v, ok := u.{{ $e.StructField }}.Get(); ok && !u.Add{{ $e.StructField }}.Present() && !u.Remove{{ $e.StructField }}.Present() {
builder.Clear{{ $e.StructField }}()
if v != nil {
builder.Add{{ $e.StructField|singular }}IDs(v...)
builder.Add{{ $e.Name|singular|pascal }}IDs(v...)
}
}
{{- end }}
Expand Down

0 comments on commit 99d5e3e

Please sign in to comment.