Skip to content

Commit 2f4925e

Browse files
liov贾一饼
andauthored
A little optimization for filed.ValueOf (#7499)
Co-authored-by: 贾一饼 <[email protected]>
1 parent 1e8baf5 commit 2f4925e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

schema/field.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ func (field *Field) setupValuerAndSetter() {
455455
// ValueOf returns field's value and if it is zero
456456
fieldIndex := field.StructField.Index[0]
457457
switch {
458-
case len(field.StructField.Index) == 1 && fieldIndex > 0:
458+
case len(field.StructField.Index) == 1 && fieldIndex >= 0:
459459
field.ValueOf = func(ctx context.Context, value reflect.Value) (interface{}, bool) {
460460
fieldValue := reflect.Indirect(value).FieldByName(field.Name)
461461
return fieldValue.Interface(), fieldValue.IsZero()
@@ -504,7 +504,7 @@ func (field *Field) setupValuerAndSetter() {
504504

505505
// ReflectValueOf returns field's reflect value
506506
switch {
507-
case len(field.StructField.Index) == 1 && fieldIndex > 0:
507+
case len(field.StructField.Index) == 1 && fieldIndex >= 0:
508508
field.ReflectValueOf = func(ctx context.Context, value reflect.Value) reflect.Value {
509509
return reflect.Indirect(value).Field(fieldIndex)
510510
}

0 commit comments

Comments
 (0)