entc/gen: remove legacy i2a support for ids (#389)

* entc/gen: remove legacy i2a support for ids

* integ: add customid tests for fk strings
This commit is contained in:
Ariel Mashraki
2020-03-16 18:19:30 +02:00
committed by GitHub
parent 15cbc5c223
commit 65f96b3593
110 changed files with 1911 additions and 1900 deletions

View File

@@ -6,7 +6,6 @@ in the LICENSE file in the root directory of this source tree.
{{ define "dialect/sql/predicate/id" -}}
func(s *sql.Selector) {
{{- if and $.ID.IsString (not $.ID.UserDefined) }}id, _ := strconv.Atoi(id){{- end }}
s.Where(sql.EQ(s.C({{ $.ID.Constant }}), id))
}
{{- end }}
@@ -15,7 +14,6 @@ in the LICENSE file in the root directory of this source tree.
{{- $op := $.Scope.Op -}}
{{- $arg := $.Scope.Arg -}}
{{- $storage := $.Scope.Storage -}}
{{- $convid := and $.ID.IsString (not $.ID.UserDefined) -}}
func(s *sql.Selector) {
{{- if $op.Variadic }}
// if not arguments were provided, append the FALSE constants,
@@ -26,10 +24,8 @@ in the LICENSE file in the root directory of this source tree.
}
v := make([]interface{}, len({{ $arg }}))
for i := range v {
{{- if $convid }}v[i], _ = strconv.Atoi({{ $arg }}[i]){{ else }}v[i] = {{ $arg }}[i]{{ end }}
v[i] = {{ $arg }}[i]
}
{{- else if $convid }}
id, _ := strconv.Atoi({{ $arg }})
{{- end }}
s.Where(sql.{{ call $storage.OpCode $op }}(s.C({{ $.ID.Constant }}), {{ if $op.Variadic }}v...{{ else }}id{{ end }}))
}