mirror of
https://github.com/ent/ent.git
synced 2026-03-05 19:35:23 +03:00
schema/field: array types are nillable (#2266)
* all: type fixes * schema/field: remove array check from goType
This commit is contained in:
@@ -129,10 +129,9 @@ func UUID(name string, typ driver.Valuer) *uuidBuilder {
|
||||
b := &uuidBuilder{&Descriptor{
|
||||
Name: name,
|
||||
Info: &TypeInfo{
|
||||
Type: TypeUUID,
|
||||
Nillable: true,
|
||||
Ident: rt.String(),
|
||||
PkgPath: indirect(rt).PkgPath(),
|
||||
Type: TypeUUID,
|
||||
Ident: rt.String(),
|
||||
PkgPath: indirect(rt).PkgPath(),
|
||||
},
|
||||
}}
|
||||
b.desc.goType(typ, valueScannerType)
|
||||
@@ -1159,7 +1158,7 @@ func (d *Descriptor) goType(typ interface{}, expectType reflect.Type) {
|
||||
},
|
||||
}
|
||||
switch t.Kind() {
|
||||
case reflect.Slice, reflect.Array, reflect.Ptr, reflect.Map:
|
||||
case reflect.Slice, reflect.Ptr, reflect.Map:
|
||||
info.Nillable = true
|
||||
}
|
||||
switch pt := reflect.PtrTo(t); {
|
||||
|
||||
@@ -230,7 +230,7 @@ func TestBytes(t *testing.T) {
|
||||
assert.Equal(t, "uuid.UUID", fd.Info.Ident)
|
||||
assert.Equal(t, "github.com/google/uuid", fd.Info.PkgPath)
|
||||
assert.Equal(t, "uuid.UUID", fd.Info.String())
|
||||
assert.True(t, fd.Info.Nillable)
|
||||
assert.False(t, fd.Info.Nillable)
|
||||
assert.True(t, fd.Info.ValueScanner())
|
||||
assert.NotEmpty(t, fd.Default.(func() uuid.UUID)())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user