mirror of https://github.com/go-gorm/gorm.git
Refact scope Fields
This commit is contained in:
parent
0d3085393e
commit
9b3be66a77
26
scope.go
26
scope.go
|
@ -315,24 +315,18 @@ func (scope *Scope) fieldFromStruct(fieldStruct reflect.StructField) *Field {
|
|||
}
|
||||
|
||||
// Fields get value's fields
|
||||
func (scope *Scope) Fields() []*Field {
|
||||
indirectValue := scope.IndirectValue()
|
||||
fields := []*Field{}
|
||||
|
||||
if !indirectValue.IsValid() {
|
||||
return fields
|
||||
}
|
||||
|
||||
scopeTyp := indirectValue.Type()
|
||||
for i := 0; i < scopeTyp.NumField(); i++ {
|
||||
fieldStruct := scopeTyp.Field(i)
|
||||
if !ast.IsExported(fieldStruct.Name) {
|
||||
continue
|
||||
func (scope *Scope) Fields() (fields []*Field) {
|
||||
if scope.IndirectValue().IsValid() {
|
||||
scopeTyp := scope.IndirectValue().Type()
|
||||
for i := 0; i < scopeTyp.NumField(); i++ {
|
||||
fieldStruct := scopeTyp.Field(i)
|
||||
if !ast.IsExported(fieldStruct.Name) {
|
||||
continue
|
||||
}
|
||||
fields = append(fields, scope.fieldFromStruct(fieldStruct))
|
||||
}
|
||||
fields = append(fields, scope.fieldFromStruct(fieldStruct))
|
||||
}
|
||||
|
||||
return fields
|
||||
return
|
||||
}
|
||||
|
||||
// Raw set sql
|
||||
|
|
Loading…
Reference in New Issue