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

Blank node context mixed in SPARQL update #892

Open
white-gecko opened this issue Jan 8, 2019 · 2 comments
Open

Blank node context mixed in SPARQL update #892

white-gecko opened this issue Jan 8, 2019 · 2 comments
Labels
bug Something isn't working SPARQL

Comments

@white-gecko
Copy link
Member

white-gecko commented Jan 8, 2019

Using the same blank id in two queries will merge the blank nodes in the graph. This is not correct since the context for a blank node in a sparql query is limited to the query.
The SPARQL 1.1 spec says:

That is, the INSERT DATA statement only allows to insert ground triples. Blank nodes in QuadDatas are assumed to be disjoint from the blank nodes in the Graph Store, i.e., will be inserted with "fresh" blank nodes. (https://www.w3.org/TR/2013/REC-sparql11-update-20130321/#insertData)

See the following in example:

import rdflib
g = rdflib.Graph()
g.serialize(format="turtle").decode("utf-8")
# empty

g.update('INSERT DATA { _:a <urn:label> "A bnode" }')
g.serialize(format="turtle").decode("utf-8")
# @prefix ns1: <urn:> .
# [] ns1:label "A bnode" .

g.update('INSERT DATA { _:a <urn:label> "Bnode 2" }')
g.serialize(format="turtle").decode("utf-8")
# @prefix ns1: <urn:> .
# [] ns1:label "A bnode",
#        "Bnode 2" .

I would expect:

…
g.update('INSERT DATA { _:a <urn:label> "Bnode 2" }')
g.serialize(format="turtle").decode("utf-8")
# @prefix ns1: <urn:> .
# [] ns1:label "A bnode" .
# [] ns1:label "Bnode 2" .
@gauri-b
Copy link

gauri-b commented May 28, 2020

Hi @white-gecko, Creating a new BNode identifier for each triple parsed seems to solve this problem, is that what we are aiming for, or did I miss something?

@white-gecko
Copy link
Member Author

Just creating a new BNode identifier for each triple would not solve the issue because this would loose the context for if triples should refer to the same blank node.

@ghost ghost added the SPARQL label Dec 23, 2021
@aucampia aucampia added the bug Something isn't working label Aug 21, 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 SPARQL
Projects
None yet
Development

No branches or pull requests

3 participants