entc/gen: remove unnecessary sqlgraph.To step on HasE predicates (#3144)

Predicate that checks existence-only do not need the 'other' table
This commit is contained in:
Ariel Mashraki
2022-12-04 13:15:16 +02:00
committed by GitHub
parent 3f1d7c960e
commit 381483e45c
91 changed files with 2 additions and 202 deletions

View File

@@ -52,16 +52,8 @@ in the LICENSE file in the root directory of this source tree.
{{- if $.HasCompositeID }}
{{- /* Query that goes from the edge schema. */}}
sqlgraph.From(Table, {{ $e.ColumnConstant }}),
sqlgraph.To({{ $e.InverseTableConstant }}, {{ print $e.Type.Name "FieldID" }}),
{{- else }}
sqlgraph.From(Table, {{ $.ID.Constant }}),
{{- if $e.Type.HasOneFieldID }}
{{- $refid := $.ID.Constant }}{{ if ne $e.Type.ID.StorageKey $.ID.StorageKey }}{{ $refid = print $e.Type.Name "FieldID" }}{{ end }}
sqlgraph.To({{ $e.TableConstant }}, {{ $refid }}),
{{- else }}
{{- /* Query that goes to the edge schema. */}}
sqlgraph.To({{ $e.TableConstant }}, {{ $e.ColumnConstant }}),
{{- end }}
{{- end }}
sqlgraph.Edge(sqlgraph.{{ $e.Rel.Type }}, {{ $e.IsInverse }}, {{ $e.TableConstant }},
{{- if $e.M2M -}}
@@ -77,6 +69,7 @@ in the LICENSE file in the root directory of this source tree.
{{- xtemplate $tmpl $ }}
{{- end }}
{{- end }}
{{- /* sqlgraph.To is meaningless on Has<E> (without predicates), because unlike Has<E>With no predicates are applied on the "other" table. */}}
sqlgraph.HasNeighbors(s, step)
}
{{- end }}