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

OPTIONAL patterns breaks CONSTRUCT commands #81

Open
alien-mcl opened this issue Nov 21, 2014 · 0 comments
Open

OPTIONAL patterns breaks CONSTRUCT commands #81

alien-mcl opened this issue Nov 21, 2014 · 0 comments

Comments

@alien-mcl
Copy link

We've noticed an abnormal behawior with CONSTRUCT commands containing OPTIONAL patterns in the WHERE block. When store is fed with i.e. a resource which has no matching triples to meet the requirements of the OPTIONAL pattern, and variables from that pattern are used in the CONSTRUCT block, the result of such a command is empty. Example SPARQL:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX lh: <http://localhost/resources/>
PREFIX voc: <http://localhost/vocabulary#>
CONSTRUCT {
    lh:test a voc:SetEnumeration .
    lh:test a voc:Command .
    lh:test voc:enumeration ?enumeration .
    ?enumeration rdf:predicate ?enumerationKey . 
    ?enumeration rdf:object ?enumerationValue . 
    lh:test voc:createdOn ?performedOn .
    lh:test voc:createdBy ?performedBy .
}
WHERE {
    lh:res a voc:SimpleDatatype .
    lh:res a voc:Datatype .
    OPTIONAL {
        lh:res voc:enumeration ?enumeration . 
        ?enumeration rdf:predicate ?enumerationKey . 
        ?enumeration rdf:object ?enumerationValue .
    }
    OPTIONAL { lh:res voc:createdOn ?performedOn . }
    OPTIONAL { lh:res voc:createdBy ?performedBy . }
}

JSON-LD resource feeding the store:

{
    "@id":"http://localhost/resources/res",
    "@type":["http://localhost/vocabulary#Datatype", "http://localhost/vocabulary#SimpleDatatype"],
    "http://localhost/vocabulary#type": [{
        "@type":"http://www.w3.org/2001/XMLSchema#anyUri",
        "@value":"http://www.w3.org/2001/XMLSchema#unsignedInt" }],
    "http://purl.org/dc/terms/identifier": [{
        "@type":"http://www.w3.org/2001/XMLSchema#NCName",
        "@value":"test" }],
    "http://www.w3.org/2000/01/rdf-schema#label": [{
        "@type":"http://www.w3.org/2001/XMLSchema#string",
        "@value":"Test" }],
    "http://localhost/vocabulary#enumeration": [{
        "http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate": [{"@value":"Test"}],
        "http://www.w3.org/1999/02/22-rdf-syntax-ns#object": [{"@value":"1"}]}]
}

Result of the store.execute is a success with an empty array of triples, while I expected something like this:

{
    "@id":"http://localhost/resources/test",
    "@type":["http://localhost/vocabulary#SetEnumeration", "http://localhost/vocabulary#Command"],
    "http://localhost/vocabulary#enumeration": [{
        "http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate": [{"@value":"Test"}],
        "http://www.w3.org/1999/02/22-rdf-syntax-ns#object": [{"@value":"1"}]}]
}

which I confirmed with other implementations of the SPARQL engines (dotNetRDF).

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

1 participant