metafacture / metafacture-fix

Work in progress towards an implementation of the Fix language for Metafacture
Apache License 2.0
6 stars 2 forks source link

Provide array-agnostic way for addressing a subfield. #305

Closed blackwinter closed 1 year ago

blackwinter commented 1 year ago

In the presence of optionally repeated fields, there is no unified way of addressing a subfield. field.subfield only works if field is not repeated (i.e., is an object internally), field.*.subfield only works if field is repeated (i.e., is an array internally).

Alternatively, enable more/all functions to support the field.subfield syntax with repeated fields. E.g., any_match() does support it, exists() doesn't.

TobiasNx commented 1 year ago

Isn't this solvable with do list? I can iterate over simple and repeated field.

blackwinter commented 1 year ago

Yes, there are several workarounds, depending on the use case. And it's still inconvenient and error-prone.

But: I opened this issue under the assumption that Metafix's behaviour was incompatible with Catmandu. Which it isn't.