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

replace_all with alternation expects multiple matching path, breaks with single matching path #249

Open
TobiasNx opened this issue Aug 9, 2022 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@TobiasNx
Copy link
Collaborator

TobiasNx commented Aug 9, 2022

Input:

{
  "describedBy" : {
    "type" : [ "BibliographicDescription" ],
    "dateCreated" : "20220711"
  }
}

FIX:
replace_all("describedBy.dateCreated|dateModified","2","?")

Expected:

{
  "describedBy" : {
    "type" : [ "BibliographicDescription" ],
    "dateCreated" : "?0??0711"
  }
}

Results in Error:

org.metafacture.metafix.FixExecutionException: Error while executing Fix expression (at file:/tmp/metafix5253049504537349638.fix, line 1): replace_all("describedBy.dateCreated|dateModified","2","?")
...
Caused by: java.lang.IllegalStateException: Expected Array or Hash, got String

See in Playground here.

Multiple Path work, see here.

@TobiasNx TobiasNx added the bug Something isn't working label Aug 9, 2022
TobiasNx added a commit to hbz/lobid-resources that referenced this issue Aug 9, 2022
It seems that alterations in path for `replace_all` automatically expects multiple matches in a record.
See: metafacture/metafacture-fix#249

Therefore I splitted the `replace_all` functions and created a function for each alteration.
@blackwinter
Copy link
Member

replace_all("describedBy.dateCreated|dateModified","2","?")

Just to be extra clear: Any other potential bugs notwithstanding, I would strongly advise against relying on this wrong behaviour in the current Metafix implementation! See #143.

@blackwinter
Copy link
Member

This also breaks with "flat" alteration.
replace_all("dateCreated|dateModified","2","?")

Good. Then we should focus on that.

@blackwinter blackwinter changed the title replace_all with alteration expects multiple matching path, breaks with single matching path replace_all with alternation expects multiple matching path, breaks with single matching path Aug 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Backlog
Development

No branches or pull requests

3 participants