Refact scope Fields
This commit is contained in:
parent
0d3085393e
commit
9b3be66a77
16
scope.go
16
scope.go
@ -315,15 +315,9 @@ func (scope *Scope) fieldFromStruct(fieldStruct reflect.StructField) *Field {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fields get value's fields
|
// Fields get value's fields
|
||||||
func (scope *Scope) Fields() []*Field {
|
func (scope *Scope) Fields() (fields []*Field) {
|
||||||
indirectValue := scope.IndirectValue()
|
if scope.IndirectValue().IsValid() {
|
||||||
fields := []*Field{}
|
scopeTyp := scope.IndirectValue().Type()
|
||||||
|
|
||||||
if !indirectValue.IsValid() {
|
|
||||||
return fields
|
|
||||||
}
|
|
||||||
|
|
||||||
scopeTyp := indirectValue.Type()
|
|
||||||
for i := 0; i < scopeTyp.NumField(); i++ {
|
for i := 0; i < scopeTyp.NumField(); i++ {
|
||||||
fieldStruct := scopeTyp.Field(i)
|
fieldStruct := scopeTyp.Field(i)
|
||||||
if !ast.IsExported(fieldStruct.Name) {
|
if !ast.IsExported(fieldStruct.Name) {
|
||||||
@ -331,8 +325,8 @@ func (scope *Scope) Fields() []*Field {
|
|||||||
}
|
}
|
||||||
fields = append(fields, scope.fieldFromStruct(fieldStruct))
|
fields = append(fields, scope.fieldFromStruct(fieldStruct))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return fields
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Raw set sql
|
// Raw set sql
|
||||||
|
Loading…
x
Reference in New Issue
Block a user