SPARQLStore customizable BNode handling by joernhees · Pull Request #513 · RDFLib/rdflib (original) (raw)
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
this implements the discussion in #512
- deprecates
CastToTerm
,TraverseSPARQLResultDOM
andlocalName
methods - deprecates
SPARQLStore(..., bNodeAsURI)
argument - adds two
SPARQLStore(..., node_to_sparql, node_from_result)
args to customize node transformations - added a doc example how to transform
BNodes
- several code cleanups
please check
The 4Store triple store understands bnode: URIs as pointing to blank nodes, which makes it possible to query and update them using its SPARQL endpoint.
…ocalName methods
also prepared configurable node_from_result arg.
def _node_to_sparql(node): |
---|
if isinstance(node, BNode): |
raise Exception( |
"SPARQLStore does not support BNodes! " |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this Exception should now say "SPARQLStore does not support BNodes by default! See ..."
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i thought so too, but as this currently raises an overly broad exception, the only thing people can do is rely on its message to actually handle it. That's why I decided against it for now and didn't change the message.
i made an issue to change all raise Exception
to something more appropriate in 5.0.0 (see #515)
This has been quite some work it seems. Except for the nitpick in my previous comment, this looks good to me.
eh, it's mostly moves, deprecations and cleanups...
thanks for reviewing, i'll merge this soon if no one objects
This looks like it'll resolve the issue I had in #511 and #512, thanks !!
joernhees added a commit that referenced this pull request
SPARQLStore customizable BNode handling, deprecations and cleanups
joernhees added a commit that referenced this pull request
- sparql_store_bnode: test changed to use _node_from_result instead of CastToTerm
@ssssam you can try by installing rdflib like this: pip install -U git+git://github.com/RDFLib/rdflib
(until 4.2.2 is released)
joernhees added a commit to joernhees/rdflib that referenced this pull request
initBindings, contexts, addN, remove, add_graph and remove_graph now call the node_to_sparql customizable function. Some support for BNode graph names added.
Add-on for RDFLib#513, see also RDFLib#511, RDFLib#512
joernhees added a commit to joernhees/rdflib that referenced this pull request
query (initBindings), contexts, addN, remove, add_graph and remove_graph now call node_to_sparql. Some support for BNode graph names added.
Add-on for RDFLib#513, see also RDFLib#511, RDFLib#512
joernhees added a commit to joernhees/rdflib that referenced this pull request
query (initBindings), contexts, addN, remove, add_graph and remove_graph now call node_to_sparql. Some support for BNode graph names added.
Add-on for RDFLib#513, see also RDFLib#511, RDFLib#512