@@ -448,21 +448,30 @@ func (schema *Schema) ParseField(fieldStruct reflect.StructField) *Field {
448448}
449449
450450// create valuer, setter when parse struct
451- func (field * Field ) setupValuerAndSetter () {
451+ func (field * Field ) setupValuerAndSetter (modelType reflect. Type ) {
452452 // Setup NewValuePool
453453 field .setupNewValuePool ()
454454
455455 // ValueOf returns field's value and if it is zero
456456 fieldIndex := field .StructField .Index [0 ]
457457 switch {
458458 case len (field .StructField .Index ) == 1 && fieldIndex >= 0 :
459- field .ValueOf = func (ctx context.Context , value reflect.Value ) (interface {}, bool ) {
460- fieldValue := reflect .Indirect (value ).FieldByName (field .Name )
459+ field .ValueOf = func (ctx context.Context , v reflect.Value ) (interface {}, bool ) {
460+ v = reflect .Indirect (v )
461+ if v .Type () != modelType {
462+ fieldValue := v .FieldByName (field .Name )
463+ return fieldValue .Interface (), fieldValue .IsZero ()
464+ }
465+ fieldValue := v .Field (fieldIndex )
461466 return fieldValue .Interface (), fieldValue .IsZero ()
462467 }
463468 default :
464469 field .ValueOf = func (ctx context.Context , v reflect.Value ) (interface {}, bool ) {
465470 v = reflect .Indirect (v )
471+ if v .Type () != modelType {
472+ fieldValue := v .FieldByName (field .Name )
473+ return fieldValue .Interface (), fieldValue .IsZero ()
474+ }
466475 for _ , fieldIdx := range field .StructField .Index {
467476 if fieldIdx >= 0 {
468477 v = v .Field (fieldIdx )
0 commit comments