sparqlalgebrajs
Advanced tools
Comparing version 2.1.0 to 2.2.0
@@ -265,16 +265,51 @@ "use strict"; | ||
let typeVals = Object.keys(types).map(key => types[key]); | ||
function recurseGraph(thingy, graph) { | ||
function recurseGraph(thingy, graph, replacement) { | ||
if (thingy.type === types.BGP) | ||
thingy.patterns = thingy.patterns.map(quad => { | ||
if (replacement) { | ||
if (quad.subject.equals(graph)) | ||
quad.subject = replacement; | ||
if (quad.predicate.equals(graph)) | ||
quad.predicate = replacement; | ||
if (quad.object.equals(graph)) | ||
quad.object = replacement; | ||
} | ||
quad.graph = graph; | ||
return quad; | ||
}); | ||
else if (thingy.type === types.PATH) | ||
else if (thingy.type === types.PATH) { | ||
const p = thingy; | ||
if (replacement) { | ||
if (p.subject.equals(graph)) | ||
p.subject = replacement; | ||
if (p.object.equals(graph)) | ||
p.object = replacement; | ||
} | ||
thingy.graph = graph; | ||
} | ||
// need to replace variables in subqueries should the graph also be a variable of the same name | ||
// unless the subquery projects that variable | ||
else if (thingy.type === types.PROJECT && !replacement) { | ||
const proj = thingy; | ||
if (!proj.variables.some(v => v.equals(graph))) | ||
replacement = generateFreshVar(); | ||
proj.input = recurseGraph(proj.input, graph, replacement); | ||
} | ||
// this can happen if the query extends an expression to the name of the graph | ||
// since the extend happens here there should be no further occurrences of this name | ||
// if there are it's the same situation as above | ||
else if (thingy.type === types.EXTEND && !replacement) { | ||
const ext = thingy; | ||
if (ext.variable.equals(graph)) | ||
replacement = generateFreshVar(); | ||
ext.input = recurseGraph(ext.input, graph, replacement); | ||
} | ||
else { | ||
for (let key of Object.keys(thingy)) { | ||
if (Array.isArray(thingy[key])) | ||
thingy[key] = thingy[key].map((x) => recurseGraph(x, graph)); | ||
thingy[key] = thingy[key].map((x) => recurseGraph(x, graph, replacement)); | ||
else if (typeVals.indexOf(thingy[key].type) >= 0) // can't do instanceof on an interface | ||
thingy[key] = recurseGraph(thingy[key], graph); | ||
thingy[key] = recurseGraph(thingy[key], graph, replacement); | ||
else if (replacement && isVariable(thingy[key]) && thingy[key].equals(graph)) | ||
thingy[key] = replacement; | ||
} | ||
@@ -281,0 +316,0 @@ } |
{ | ||
"name": "sparqlalgebrajs", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "Convert SPARQL to SPARQL algebra", | ||
@@ -13,21 +13,20 @@ "author": "Joachim Van Herwegen", | ||
"dependencies": { | ||
"@rdfjs/data-model": "^1.1.1", | ||
"fast-deep-equal": "^2.0.1", | ||
"@rdfjs/data-model": "^1.1.2", | ||
"fast-deep-equal": "^3.1.1", | ||
"minimist": "^1.2.0", | ||
"rdf-string": "^1.3.1", | ||
"sparqljs": "^3.0.0" | ||
"sparqljs": "^3.0.1" | ||
}, | ||
"devDependencies": { | ||
"@types/chai": "^4.1.4", | ||
"@types/lodash.isequal": "^4.5.3", | ||
"@types/chai": "^4.2.7", | ||
"@types/minimist": "^1.2.0", | ||
"@types/mocha": "^5.2.6", | ||
"@types/node": "^12.0.2", | ||
"@types/rdf-js": "^2.0.1", | ||
"@types/mocha": "^5.2.7", | ||
"@types/node": "^13.1.4", | ||
"@types/rdf-js": "^2.0.7", | ||
"chai": "^4.1.2", | ||
"mocha": "^6.1.1", | ||
"nyc": "^14.1.0", | ||
"mocha": "^6.2.2", | ||
"nyc": "^15.0.0", | ||
"pre-commit": "^1.2.2", | ||
"ts-node": "^8.0.2", | ||
"typescript": "^3.3.3333" | ||
"ts-node": "^8.5.4", | ||
"typescript": "^3.7.4" | ||
}, | ||
@@ -34,0 +33,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
87531
11
2093
+ Addedfast-deep-equal@3.1.3(transitive)
- Removedfast-deep-equal@2.0.1(transitive)
Updated@rdfjs/data-model@^1.1.2
Updatedfast-deep-equal@^3.1.1
Updatedsparqljs@^3.0.1