File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -514,12 +514,19 @@ func (field *Field) setupValuerAndSetter(modelType reflect.Type) {
514514 // ReflectValueOf returns field's reflect value
515515 switch {
516516 case len (field .StructField .Index ) == 1 && fieldIndex >= 0 :
517- field .ReflectValueOf = func (ctx context.Context , value reflect.Value ) reflect.Value {
518- return reflect .Indirect (value ).Field (fieldIndex )
517+ field .ReflectValueOf = func (ctx context.Context , v reflect.Value ) reflect.Value {
518+ v = reflect .Indirect (v )
519+ if v .Type () != modelType {
520+ return v .FieldByName (field .Name )
521+ }
522+ return v .Field (fieldIndex )
519523 }
520524 default :
521525 field .ReflectValueOf = func (ctx context.Context , v reflect.Value ) reflect.Value {
522526 v = reflect .Indirect (v )
527+ if v .Type () != modelType {
528+ return v .FieldByName (field .Name )
529+ }
523530 for idx , fieldIdx := range field .StructField .Index {
524531 if fieldIdx >= 0 {
525532 v = v .Field (fieldIdx )
You can’t perform that action at this time.
0 commit comments