Callidon / sparql-engine

🚂 A framework for building SPARQL query engines in Javascript/Typescript
https://callidon.github.io/sparql-engine
MIT License
97 stars 14 forks source link

Error: Unknown graph with iri ?g #76

Open tpluscode opened 2 years ago

tpluscode commented 2 years ago

Describe the bug

Insert/Where with a graph variable fails

To Reproduce

I tried to run the following query

PREFIX sh: <http://www.w3.org/ns/shacl#>

INSERT {
  GRAPH ?g { 
    ?shape sh:property ?property .
    ?property sh:group ?group . 
  }
} WHERE {
  GRAPH ?g { 
    ?shape <http://example.com/group> ?group .
    ?group <http://example.com/property> ?property . 
  }
}

This fails as seen below

node_modules/sparql-engine/dist/rdf/hashmap-dataset.js:81
            throw new Error("Unknown graph with iri " + iri);
            ^

Error: Unknown graph with iri ?g
    at HashMapDataset.getNamedGraph (node_modules/sparql-engine/dist/rdf/hashmap-dataset.js:81:19)
    at UpdateStageBuilder._buildInsertConsumer (node_modules/sparql-engine/dist/engine/stages/update-stage-builder.js:208:81)
    at node_modules/sparql-engine/dist/engine/stages/update-stage-builder.js:192:30
    at Array.map (<anonymous>)
    at UpdateStageBuilder._handleInsertDelete (node_modules/sparql-engine/dist/engine/stages/update-stage-builder.js:191:60)
    at node_modules/sparql-engine/dist/engine/stages/update-stage-builder.js:77:38
    at Array.map (<anonymous>)
    at UpdateStageBuilder.execute (node_modules/sparql-engine/dist/engine/stages/update-stage-builder.js:71:53)
    at PlanBuilder.build (node_modules/sparql-engine/dist/engine/plan-builder.js:211:73)
    at test.js:66:30

Expected behavior

The query should succeed, since ?g is a variable bound in the WHERE clause and not an IRI