Closed alovak closed 2 years ago
While this is a breaking change this PR resolves a pretty annoying bug that would take a while for someone to investigate, so it makes sense to fix. Also the original change is ~2 weeks old in this repository so few people have likely adopted it.
When we marshal/unmarshal field values, we match struct fields by name first and by
index
tag second. When we check the field name we use regexp:^F\d+$
(field name starts withF
and has digits after it). Because composite fields can have tag names that are not digits, we only check that field starts withF
with the regexp:^F.+$
.So, if you marshal/unmarshal composite field that starts with
F
and also has index, then the index tag will be ignored. Imagine you have tag01
and a struct:Guess what? You will spend time trying to understand why tag
01
is not set when you marhsal/unmarshal data. And it's because the composite field will takeorwadingInsitutionCode
as an index of the field and will try to find a spec for such field.To avoid such cases, we are changing the field name matching priorities by checking the
index
tag first and the field name second.Technically, it can be a breaking change if you use
index
tag on the struct for something else.