mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
entc/gen: correctly handle custom storage-key for id fields (#643)
Fixed #621
This commit is contained in:
@@ -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 }}"
|
||||
|
||||
Reference in New Issue
Block a user