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

Simplification throws error when encountering somevalue/novalue qualifiers #47

Closed
noinkling opened this issue Mar 16, 2019 · 2 comments
Closed

Comments

@noinkling
Copy link
Contributor

Real examples:

var e = data.entities.Q19180293
wdk.simplify.qualifiers(e.claims.P1433[0].qualifiers.P156[0])
TypeError: Cannot destructure property `value` of 'undefined' or 'null'.
    at Object.simplifyClaim (/<...>/node_modules/wikidata-sdk/lib/helpers/simplify_claims.js:96:17)
    at parse (/<...>/node_modules/wikidata-sdk/lib/helpers/parse_claim.js:84:31)
    at Object.entity (/<...>/node_modules/wikidata-sdk/lib/helpers/parse_claim.js:9:40)
    at prefixedId (/<...>/node_modules/wikidata-sdk/lib/helpers/parse_claim.js:18:21)

Which means of course that following functions all crash too:

wdk.simplify.propertyQualifiers(e.claims.P1433[0].qualifiers.P156)
wdk.simplify.qualifier(e.claims.P1433[0].qualifiers)
wdk.simplify.claim(e.claims.P1433[0], { keepQualifiers: true })
wdk.simplify.propertyClaims(e.claims.P1433, { keepQualifiers: true })
...
wdk.simplify.entities(data.entities, { keepQualifiers: true })

Setting somevalueValue and novalueValue doesn't help.

P.S. The naming for the simplify.qualifier and simplify.qualifiers functions is a little confusing, as if they're swapped. But they are documented correctly. Was this intentional?

maxlath added a commit that referenced this issue Mar 16, 2019
@maxlath
Copy link
Owner

maxlath commented Mar 16, 2019

I added support for novalue and somevalue qualifiers in e539d1f and fixed the simplify.qualifier and simplify.qualifiers swap in ed0e7a4.

Patches published in v5.16.1

Thank you for reporting those issues!

@noinkling
Copy link
Contributor Author

noinkling commented Mar 16, 2019

Thank you 👍

I think the naming swap should be considered a breaking change and probably requires a major version bump though, even if it was technically a mistake in the first place. I've also opened a tiny PR for the docs: #48

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants