schema/field: array types are nillable (#2266)

* all: type fixes

* schema/field: remove array check from goType
This commit is contained in:
Clarence
2022-01-13 15:39:11 +04:00
committed by GitHub
parent 565e4ffdfc
commit eca70b8490
21 changed files with 240 additions and 9 deletions

View File

@@ -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); {

View File

@@ -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)())