-
Notifications
You must be signed in to change notification settings - Fork 560
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
Fix simple literals returned as NULL using SERVICE (issue #1278) #1894
Conversation
… sparql/results/jsonresults parser.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, a bit swamped fixing bugs and reviewing/fixing older PRs right now so I won't be able to take a detailed look until later, but it would be good to expand testing for SERVICE
directive to ensure that each branch here is covered, which I'm not sure it will be, though I may be wrong.
Also it seems your test is failing: https://github.com/RDFLib/rdflib/runs/6341689732?check_suite_focus=true#step:9:372 def test():
"""Test service returns simple literals not as NULL.
Issue: https://github.com/RDFLib/rdflib/issues/1278
"""
g = Graph()
q = """SELECT ?s ?p ?o
WHERE {
SERVICE <https://dbpedia.org/sparql> {
VALUES (?s ?p ?o) {(<http://example.org/a> <http://example.org/b> "c")}
}
}"""
> assert results.bindings[0].get(Variable("o")) == Literal("c")
E NameError: name 'results' is not defined |
Accidentally clicked approve instead of comment.
Thanks for your support, the failing test should be fixed now. This test uses a similar approach as the existing SERVICE tests: https://github.com/RDFLib/rdflib/blob/eba13739e1d24b3e52697a1ec9545a361116951f/test/test_sparql/test_service.py. When I have time I will have a look at your suggestions for improving the test(s). |
Okay in that case I think it is fine then, but maybe it would be good to add this test to |
I added a more general test for different node types returned by a SERVICE clause to test_service.py. |
@gitmpje will review tonight, I don't think there are any issues with the code, but I may move tests around slightly, thank you for the PR. |
Also make existing tests stricter.
- Use longer variable names so it is easier to read - Add type hints - Add comment explaining the reason for `typed-literal` - Improved exception in case of invalid/unsupported type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gitmpje thanks for the PR. I added more tests to your branch and made some minor mostly cosmetic improvements, let me know if there are any concerns you have with the changes.
No concerns from my side, thank you for your comments and support! |
@RDFLib/core I will merge this by 2022-05-17 if there is no further feedback. |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Summary of changes
Fixes #1278 simple literals returned as NULL. The resolution uses same logic as here:
rdflib/rdflib/plugins/sparql/results/jsonresults.py
Lines 89 to 107 in 6f2c11c
Checklist
the same change.
so maintainers can fix minor issues and keep your PR up to date.