Skip to content

Commit

Permalink
Merge pull request #130 from stephenafamo/fix-setter-if-relationships
Browse files Browse the repository at this point in the history
Generate setter if a table has relationships
  • Loading branch information
stephenafamo authored Nov 18, 2023
2 parents e3353da + 12381f4 commit 68600c9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 1 addition & 2 deletions gen/templates/models/01_types.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ type {{$tAlias.DownSingular}}R struct {
}
{{- end}}

{{if .Table.PKey -}}
{{if or .Table.PKey .Table.Relationships -}}
// {{$tAlias.UpSingular}}Setter is used for insert/upsert/update operations
// All values are optional, and do not have to be set
// Generated columns are not included
Expand Down Expand Up @@ -223,4 +223,3 @@ func {{$tAlias.UpSingular}}Where[Q {{$.Dialect}}.Filterable]() {{$tAlias.DownSin
{{end -}}
}
}

2 changes: 2 additions & 0 deletions gen/templates/models/11_rel_ops.go.tpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{if .Table.PKey -}}
{{$table := .Table}}
{{$tAlias := .Aliases.Table $table.Key -}}

Expand Down Expand Up @@ -320,3 +321,4 @@

{{end -}}{{end -}}

{{- end}}

0 comments on commit 68600c9

Please sign in to comment.