Open TobiasNx opened 1 month ago
When using set_array this seems to work. Not sure why:
set_array("RSWK[]")
do list(path: "650??", "var": "$i")
copy_field("$i.a", "RSWK[].$append.subjectTopicName")
copy_field("$i.v", "RSWK[].$last.subjectGenre")
end
replace_all("RSWK[].*.subjectGenre", "[.]$", "")
retain("RSWK[]")
Unfortunately the playground does not show the new behavior yet.
It seems to be caused by copy_field
carrying over the old value's path (650 .v
) to the new location (RSWK[].$last.subjectGenre
). That way, replace_all
gets confused and assumes that the target position for the transformed value must be the first array element.
It can be solved by explicitly telling copy_field
(and other call sites in the same vein) to ignore the old value's path (.withPathSet(null)
; see #380). But I'm unsure whether this is the right approach; at the very least, it modifies the original value's path which might cause subsequent issues down the line.
I'm sorry to say this, but our path handling is quite a mess ;)
See: https://github.com/metafacture/metafacture-fix/pull/376
https://github.com/metafacture/metafacture-fix/tree/d18a5035d2b74508d685ec863c91e4382aff2c26/metafix/src/test/resources/org/metafacture/metafix/integration/method/fromXml/toJson/replace_allInOptionalSubfieldOfRepeatedObjectsWithAsterisk
in:
Out:
Expected: