entc/gen: fix name conflict in type package (#1274)

Fixed #1268
This commit is contained in:
Ariel Mashraki
2021-02-25 14:26:04 +02:00
committed by GitHub
parent a0c3976ee5
commit 31ec081b0e
11 changed files with 312 additions and 9 deletions

File diff suppressed because one or more lines are too long

View File

@@ -6,7 +6,7 @@ in the LICENSE file in the root directory of this source tree.
{{/* constants needed for gremlin dialects. */}}
{{ define "dialect/gremlin/meta/constants" }}
{{ range $_, $e := $.Edges }}{{ $label := $e.LabelConstant -}}
{{ range $e := $.Edges }}{{ $label := $e.LabelConstant -}}
{{ if $e.IsInverse }}{{- $label = $e.InverseLabelConstant -}}
// {{ $label }} holds the string label denoting the {{ lower $e.Name }} inverse edge type in the database.
{{ else -}}

View File

@@ -35,12 +35,13 @@ func ID(id {{ $.ID.Type }}) predicate.{{ $.Name }} {
{{ end }}
{{ range $f := $.Fields }}
{{ $func := $f.StructField }}
{{/* JSON cannot be compared using "=" and Enum has a type defined with the field name */}}
{{ $hasP := not (or $f.IsJSON $f.IsEnum) }}
{{ $comparable := $f.ConvertedToBasic }}
{{- if and $hasP $comparable }}
{{ $undeclared := (and (ne $func "Label") (ne $func "Hooks") (ne $func "Policy")) }}
{{- if and $hasP $comparable $undeclared }}
{{ $arg := "v" }}
{{ $func := $f.StructField }}
// {{ $func }} applies equality check predicate on the {{ quote $f.Name }} field. It's identical to {{ $func }}EQ.
func {{ $func }}({{ $arg }} {{ $f.Type }}) predicate.{{ $.Name }} {
{{- if $f.HasGoType }}