Skip to content
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

Writing into array with same name but with and without leading * merges both array into one #656

Open
TobiasNx opened this issue Jan 30, 2025 · 7 comments

Comments

@TobiasNx
Copy link
Contributor

In principal it is possible to create elements and array with leading * as part of the name.

But if you write an array on the same level with same name but one with and one without leading *, the two disctinct arrays are merged:

See in example in playground.

Fix:

add_field("test.$append","TEST1")
add_field("*test.$append","TEST2")

Result:

test: "TEST1"
test: "TEST2"

Expected:

test: "TEST1"
*test: "TEST2"

This came up in #589 when transforming marc data to edm, since rdf-macro expects * as refrence marker.

@blackwinter
Copy link
Member

The asterisk (*) is a wildcard, so *test matches test.

@TobiasNx
Copy link
Contributor Author

Interestingly:

add_field("*test2","TEST2")
add_field("test4.*test.$append","TEST6")

works

---
'*test2': "TEST2"
test4:
  '*test': "TEST6"

I am also not sure if we should fix this?

@blackwinter
Copy link
Member

I would consider it a bug if the wildcard becomes part of the field name just because it didn't match any preexisting field.

@TobiasNx
Copy link
Contributor Author

Morph was able to create such elements e.g. here. This was the precondition of the marker * which came up in #589 and try to make configurable in #657

@blackwinter
Copy link
Member

Morph was able to create such elements

That's definitely a surprise. Would have to look into it more thoroughly.

@blackwinter
Copy link
Member

The reason that it works in Metamorph is that it doesn't evaluate wildcards in the target field (name), only in the source field (source). Metafix, on the other hand, supports wildcards in both source and target fields.

The only solution I can think of right now is to allow escaping of special characters in WildcardTrie (*, ?, |) and SimpleRegexTrie ([, ]). This might also be valuable in its own right.

@TobiasNx
Copy link
Contributor Author

TobiasNx commented Feb 6, 2025

In my opinion this is not urgent since we enabled this: #657

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

2 participants