entc/gen: correctly handle custom storage-key for id fields (#643)

Fixed #621
This commit is contained in:
Ariel Mashraki
2020-07-28 10:14:21 +03:00
committed by GitHub
parent 5f16308551
commit dd3cdc147d
21 changed files with 71 additions and 27 deletions

View File

@@ -6,9 +6,15 @@ in the LICENSE file in the root directory of this source tree.
{{/* constants needed for sql dialects. */}}
{{ define "dialect/sql/meta/constants" }}
{{- range $t := $.RelatedTypes }}
{{- if ne $t.ID.StorageKey $.ID.StorageKey }}
// {{ $t.Name }}FieldID holds the string denoting the id field of the {{ $t.Name }}.
{{ $t.Name }}FieldID = "{{ $t.ID.StorageKey }}"
{{- end }}
{{- end }}
// Table holds the table name of the {{ lower $.Name }} in the database.
Table = "{{ $.Table }}"
{{- range $_, $e := $.Edges }}
{{- range $e := $.Edges }}
// {{ $e.TableConstant }} is the table the holds the {{ $e.Name }} relation/edge.
{{- if $e.M2M }} The primary key declared below.{{ end }}
{{ $e.TableConstant }} = "{{ $e.Rel.Table }}"