mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
entc/gen: allow if field to use field.Other with custom types (#2309)
* fix ID with field.Other comparing with zero * fix lint * Update entc/integration/customid/ent/schema/other.go Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com> * re-generate code Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
This commit is contained in:
@@ -174,7 +174,7 @@ func ({{ $receiver }} *{{ $builder }}) Save(ctx context.Context) ([]*{{ $.Name }
|
||||
}
|
||||
mutation.{{ $.ID.BuilderField }} = &nodes[i].{{ $.ID.StructField }}
|
||||
mutation.done = true
|
||||
{{- if and $.ID.UserDefined (or $.ID.IsString $.ID.IsUUID $.ID.IsBytes) }}
|
||||
{{- if and $.ID.UserDefined (or $.ID.IsString $.ID.IsUUID $.ID.IsBytes $.ID.IsOther) }}
|
||||
{{- /* Do nothing, because these 2 types must be supplied by the user. */ -}}
|
||||
{{- else }}
|
||||
if specs[i].ID.Value != nil {{ if $.ID.UserDefined }}&& nodes[i].ID == 0{{ end }} {
|
||||
|
||||
@@ -51,7 +51,7 @@ func ({{ $receiver }} *{{ $.Name }}) assignValues(columns []string, values []int
|
||||
for {{ $idx }} := range columns {
|
||||
switch columns[{{ $idx }}] {
|
||||
case {{ $.Package }}.{{ $.ID.Constant }}:
|
||||
{{- if and $.ID.UserDefined (or $.ID.IsString $.ID.IsUUID $.ID.IsBytes) }}
|
||||
{{- if and $.ID.UserDefined (or $.ID.IsString $.ID.IsUUID $.ID.IsBytes $.ID.IsOther) }}
|
||||
{{- with extend $ "Idx" $idx "Field" $.ID "Rec" $receiver }}
|
||||
{{ template "dialect/sql/decode/field" . }}
|
||||
{{- end }}
|
||||
|
||||
Reference in New Issue
Block a user