mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
schema/field: support unique bytes (#1720)
This commit is contained in:
@@ -19,8 +19,8 @@ func ({{ $receiver }} *{{ $builder }}) sqlSave(ctx context.Context) (*{{ $.Name
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
{{- if and $.ID.UserDefined (or $.ID.IsString $.ID.IsUUID) }}
|
||||
{{- /* Do nothing, because these 2 types must be supplied by the user. */ -}}
|
||||
{{- if and $.ID.UserDefined (or $.ID.IsString $.ID.IsUUID $.ID.IsBytes) }}
|
||||
{{- /* Do nothing, because these 3 types must be supplied by the user. */ -}}
|
||||
{{- else }}
|
||||
{{- if $.ID.UserDefined }}
|
||||
if _node.ID == 0 {
|
||||
@@ -125,7 +125,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) }}
|
||||
{{- if and $.ID.UserDefined (or $.ID.IsString $.ID.IsUUID $.ID.IsBytes) }}
|
||||
{{- /* Do nothing, because these 2 types must be supplied by the user. */ -}}
|
||||
{{- else }}
|
||||
{{- if $.ID.UserDefined }}
|
||||
|
||||
@@ -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) }}
|
||||
{{- if and $.ID.UserDefined (or $.ID.IsString $.ID.IsUUID $.ID.IsBytes) }}
|
||||
{{- with extend $ "Idx" $idx "Field" $.ID "Rec" $receiver }}
|
||||
{{ template "dialect/sql/decode/field" . }}
|
||||
{{- end }}
|
||||
@@ -71,7 +71,7 @@ func ({{ $receiver }} *{{ $.Name }}) assignValues(columns []string, values []int
|
||||
{{- range $i, $fk := $.UnexportedForeignKeys }}
|
||||
{{- $f := $fk.Field }}
|
||||
case {{ if $fk.UserDefined }}{{ $.Package }}.{{ $.ID.Constant }}{{ else }}{{ $.Package }}.ForeignKeys[{{ $i }}]{{ end }}:
|
||||
{{- if or $fk.UserDefined (and $f.UserDefined (or $f.IsString $f.IsUUID)) }}
|
||||
{{- if or $fk.UserDefined (and $f.UserDefined (or $f.IsString $f.IsUUID $.ID.IsBytes)) }}
|
||||
{{- with extend $ "Idx" $idx "Field" $f "Rec" $receiver "StructField" $fk.StructField }}
|
||||
{{ template "dialect/sql/decode/field" . }}
|
||||
{{- end }}
|
||||
|
||||
Reference in New Issue
Block a user