Skip to content
Myr

fix ignore walking on form mapping (#1942) (#1943)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Dmitry Kutakov · committed by thinkerou · parent 0f95195 · Browse files · 2 files+14 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+14 added−3 removed

  • other:+14 added−3 removed

2 files+14 added−3 removed

modified:binding/form_mapping_test.go+10 added
267 unmodified lines
268 err := mappingByPtr(&s, formSource{"M": {`{"one": 1}`}}, "form")269 assert.NoError(t, err)270 assert.Equal(t, map[string]int{"one": 1}, s.M)271}272273func TestMappingIgnoredCircularRef(t *testing.T) {274 type S struct {275 S *S `form:"-"`276 }277 var s S278279 err := mappingByPtr(&s, formSource{}, "form")280 assert.NoError(t, err)281}
modified:binding/form_mapping.go+4 added-3 removed
49 unmodified lines
50 return err51}5253func mapping(value reflect.Value, field reflect.StructField, setter setter, tag string) (bool, error) {54 if field.Tag.Get(tag) == "-" { // just ignoring this field55 return false, nil56 }5758 var vKind = value.Kind()5960 if vKind == reflect.Ptr {61 var isNew bool
53 unmodified lines
115116 tagValue = field.Tag.Get(tag)117 tagValue, opts := head(tagValue, ",")118115 if tagValue == "-" { // just ignoring this field116 return false, nil117 }119 if tagValue == "" { // default value is FieldName120 tagValue = field.Name121 }122 if tagValue == "" { // when field is "emptyField" variable
228 unmodified lines