mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
ent/schema: rename nullable to nillable
Reviewed By: idoshveki Differential Revision: D16687892 fbshipit-source-id: e8cfaaf1241e94c2de0a9fe9077326339d593716
This commit is contained in:
committed by
Facebook Github Bot
parent
25f5a2ef01
commit
619b63d5f7
@@ -15,7 +15,7 @@ func ({{ $receiver }} *{{ $builder }}) sqlSave(ctx context.Context) (*{{ $.Name
|
||||
{{- range $_, $f := $.Fields }}
|
||||
if {{ $receiver }}.{{- $f.StructField }} != nil {
|
||||
builder.Set({{ $.Package }}.{{ $f.Constant }}, *{{ $receiver }}.{{ $f.StructField }})
|
||||
{{ $.Receiver }}.{{ pascal $f.Name }} = {{ if not $f.Nullable }}*{{ end }}{{ $receiver }}.{{ $f.StructField }}
|
||||
{{ $.Receiver }}.{{ pascal $f.Name }} = {{ if not $f.Nillable }}*{{ end }}{{ $receiver }}.{{ $f.StructField }}
|
||||
}
|
||||
{{- end }}
|
||||
query, args := builder.Query()
|
||||
|
||||
@@ -7,7 +7,7 @@ func ({{ $receiver }} *{{ $.Name }}) FromRows(rows *sql.Rows) error {
|
||||
var {{ $scan }} struct {
|
||||
ID {{ if $.ID.IsString }}int{{ else }}{{ $.ID.Type }}{{ end }}
|
||||
{{ range $_, $f := $.Fields }}
|
||||
{{- pascal $f.Name }} {{ if or $f.Nullable $f.Optional }}{{ $f.NullType }}{{ else }}{{ $f.Type }}{{ end }}
|
||||
{{- pascal $f.Name }} {{ if or $f.Nillable $f.Optional }}{{ $f.NullType }}{{ else }}{{ $f.Type }}{{ end }}
|
||||
{{ end }}
|
||||
}
|
||||
// the order here should be the same as in the `{{ $.Package }}.Columns`.
|
||||
@@ -21,7 +21,7 @@ func ({{ $receiver }} *{{ $.Name }}) FromRows(rows *sql.Rows) error {
|
||||
}
|
||||
{{ $receiver }}.ID = {{ if $.ID.IsString }}strconv.Itoa({{ $scan }}.ID){{ else }}{{ $scan }}.ID{{ end }}
|
||||
{{- range $_, $f := $.Fields }}
|
||||
{{- if $f.Nullable }}
|
||||
{{- if $f.Nillable }}
|
||||
{{- if $f.IsTime }}
|
||||
{{ $receiver }}.{{ pascal $f.Name }} = &{{ $scan }}.{{ pascal $f.Name }}
|
||||
{{- else }}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
{{ define "dialect/sql/predicate/id/ops" -}}
|
||||
{{- $op := $.Scope.Op -}}
|
||||
{{- $arg := $.Scope.Arg -}}
|
||||
{{- $storage := $.Scope.Storage -}}
|
||||
func(s *sql.Selector) {
|
||||
{{- if $op.Variadic }}
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
@@ -23,7 +24,7 @@
|
||||
{{- else if $.ID.IsString }}
|
||||
id, _ := strconv.Atoi({{ $arg }})
|
||||
{{- end }}
|
||||
s.Where(sql.{{ $op.Name }}(s.C({{ $.ID.Constant }}), {{ if $op.Variadic }}v...{{ else }}id{{ end }}))
|
||||
s.Where(sql.{{ call $storage.OpCode $op }}(s.C({{ $.ID.Constant }}), {{ if $op.Variadic }}v...{{ else }}id{{ end }}))
|
||||
}
|
||||
{{- end }}
|
||||
|
||||
@@ -38,6 +39,7 @@
|
||||
{{- $f := $.Scope.Field -}}
|
||||
{{- $op := $.Scope.Op -}}
|
||||
{{- $arg := $.Scope.Arg -}}
|
||||
{{- $storage := $.Scope.Storage -}}
|
||||
func(s *sql.Selector) {
|
||||
{{- if $op.Variadic }}
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
@@ -47,7 +49,7 @@
|
||||
return
|
||||
}
|
||||
{{- end }}
|
||||
s.Where(sql.{{ $op.Name }}(s.C({{ $f.Constant }}){{ if not $op.Niladic }}, v{{ if $op.Variadic }}...{{ end }}{{ end }}))
|
||||
s.Where(sql.{{ call $storage.OpCode $op }}(s.C({{ $f.Constant }}){{ if not $op.Niladic }}, v{{ if $op.Variadic }}...{{ end }}{{ end }}))
|
||||
}
|
||||
{{- end }}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ func ({{ $receiver }} *{{ $builder }}) sqlSave(ctx context.Context) ({{ $ret }}
|
||||
update = true
|
||||
builder.Set({{ $.Package }}.{{ $f.Constant }}, *{{ $receiver }}.{{ $f.StructField }})
|
||||
{{- if $one }}
|
||||
{{- if $f.Nullable }}
|
||||
{{- if $f.Nillable }}
|
||||
{{ $.Receiver }}.{{ pascal $f.Name }} = {{ $receiver }}.{{ $f.StructField }}
|
||||
{{- else }}
|
||||
{{ $.Receiver }}.{{ pascal $f.Name }} = *{{ $receiver }}.{{ $f.StructField }}
|
||||
|
||||
Reference in New Issue
Block a user