New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
copy_field
array of strings with a single value create internally no arrays
#239
Comments
copy_field
array of strings with a single valuecopy_field
array of strings with a single value are internally no arrays
copy_field
array of strings with a single value are internally no arrayscopy_field
array of strings with a single value create internally no arrays
E.g., with the following internal data: { "your": [ { "name": "max" }, { "name": "mo" } ] } Retrieving [ "max", "mo" ] As for your original |
I would say this is not the same case. But I do not know if this makes a difference. While you are interested here in a single element of an array of objects: In my case you are interested in the array as a whole wether it be with a single element, multiple elements or none. Also how is catmandu behaving? |
https://github.com/TobiasNx/Catmandu-Testing/tree/master/ArrayHandling It seems that Catmandu is able to work with single and no value array of strings. |
One idea I have conceptually is, that you introduce a conditional control if the original value type is an array. |
While I see the conceptual point here, I don't quite see the practical problem. Why not add the And while it might be possible to preserve the original type (based on the path), I don't think it's worth the effort here. We already deviate from Catmandu since we need to specify the array marker in the fix (as in #240), and there is an easy solution, adding the array marker. Internally, the values are always in an array, and the array marker is used precisely to control if we want to output as an array or not. The empty array is a different topic, and we should fix that, but we have a separate issue for that (#195). |
Since I used the already established |
This again popped up. And I am still not sure why this is difficult: A copied array/list of strings with a single element is not copied as such, but copied as a simple string element. |
@blackwinter you already introduced a test if the elememt is an array here with 2427f2c: metafacture-fix/metafix/src/main/java/org/metafacture/metafix/FixMethod.java Lines 170 to 177 in 6810484
would it be possible to adjust the behaviour with single value arrays here too? |
Not sure why I am assigned here. I remember that @blackwinter suggested a solution that is not "universal" for every scenario in our meeting. @blackwinter do you remember? |
When copying an array of strings that has a single value, fix seems not to copy it as an array but an simple string-element.
This is not spotted since fix outputs simple stringelements that have
[]
at the end of their name as arrays even if they are not handled as arrays fix-internally. I try to come up with an integration test for this.Here is an example for it.
This illustrates it even better:
It is disguised by the handling of the output by the json decoder.
This problem could be connected to: #116 and #195
It seems that array are not copied as arrays at all but each value individually. Therefore #195 empty arrays cannot be copied and arrays of strings with single values are not copied as simple string elements. With multiple values the behaviour therefore seems to be identical to the non-destructive behaviour of
copy_field/move_field
#116 .The text was updated successfully, but these errors were encountered: