mirror of
https://github.com/ent/ent.git
synced 2026-04-28 05:30:56 +03:00
schema/field: use reflect string for rtype identifier
This commit is contained in:
committed by
Ariel Mashraki
parent
b20d521593
commit
9b73ca3eef
@@ -1069,6 +1069,7 @@ func (d *Descriptor) goType(typ interface{}, expectType reflect.Type) {
|
||||
rtype: t,
|
||||
Kind: t.Kind(),
|
||||
Name: tv.Name(),
|
||||
Ident: tv.String(),
|
||||
PkgPath: tv.PkgPath(),
|
||||
Methods: make(map[string]struct{ In, Out []*RType }, t.NumMethod()),
|
||||
},
|
||||
@@ -1088,12 +1089,12 @@ func (d *Descriptor) goType(typ interface{}, expectType reflect.Type) {
|
||||
in := make([]*RType, m.Type.NumIn()-1)
|
||||
for j := range in {
|
||||
arg := m.Type.In(j + 1)
|
||||
in[j] = &RType{Name: arg.Name(), Kind: arg.Kind(), PkgPath: arg.PkgPath()}
|
||||
in[j] = &RType{Name: arg.Name(), Ident: arg.String(), Kind: arg.Kind(), PkgPath: arg.PkgPath()}
|
||||
}
|
||||
out := make([]*RType, m.Type.NumOut())
|
||||
for j := range out {
|
||||
ret := m.Type.Out(j)
|
||||
out[j] = &RType{Name: ret.Name(), Kind: ret.Kind(), PkgPath: ret.PkgPath()}
|
||||
out[j] = &RType{Name: ret.Name(), Ident: ret.String(), Kind: ret.Kind(), PkgPath: ret.PkgPath()}
|
||||
}
|
||||
info.RType.Methods[m.Name] = struct{ In, Out []*RType }{in, out}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ package field
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path"
|
||||
"reflect"
|
||||
"strings"
|
||||
)
|
||||
@@ -187,7 +186,8 @@ var (
|
||||
// RType holds a serializable reflect.Type information of
|
||||
// Go object. Used by the entc package.
|
||||
type RType struct {
|
||||
Name string
|
||||
Name string // reflect.Type.Name
|
||||
Ident string // reflect.Type.String
|
||||
Kind reflect.Kind
|
||||
PkgPath string
|
||||
Methods map[string]struct{ In, Out []*RType }
|
||||
@@ -206,7 +206,7 @@ func (r *RType) String() string {
|
||||
if r.rtype != nil {
|
||||
return r.rtype.String()
|
||||
}
|
||||
return path.Base(r.PkgPath) + "." + r.Name
|
||||
return r.Ident
|
||||
}
|
||||
|
||||
// IsPtr reports if the reflect-type is a pointer type.
|
||||
|
||||
Reference in New Issue
Block a user