Skip to content

Commit

Permalink
Fix blank nodes in triple terms not being converted to variables
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks authored and joachimvh committed Jan 29, 2025
1 parent 2fc786f commit 0840757
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 19 deletions.
12 changes: 10 additions & 2 deletions lib/sparqlAlgebra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -920,8 +920,8 @@ function translateBlankNodesToVariables (res: Algebra.Operation) : Algebra.Opera
return Util.mapOperation(res, {
[Algebra.types.DELETE_INSERT]: (op: Algebra.DeleteInsert) => {
// Make sure blank nodes remain in the INSERT block, but do update the WHERE block
return {
result: factory.createDeleteInsert(op.delete, op.insert, op.where && translateBlankNodesToVariables(op.where)),
return {
result: factory.createDeleteInsert(op.delete, op.insert, op.where && translateBlankNodesToVariables(op.where)),
recurse: false,
};
},
Expand Down Expand Up @@ -967,6 +967,14 @@ function translateBlankNodesToVariables (res: Algebra.Operation) : Algebra.Opera
}
return variable;
}
if (term.termType === 'Quad') {
return factory.dataFactory.quad(
blankToVariable(term.subject),
blankToVariable(term.predicate),
blankToVariable(term.object),
blankToVariable(term.graph),
);
}
return term;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
"type": "pattern",
"termType": "Quad",
"subject": {
"termType": "BlankNode",
"termType": "Variable",
"value": "e_b"
},
"predicate": {
Expand Down Expand Up @@ -195,4 +195,4 @@
"value": "s"
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"value": "http://example.com/ns#p"
},
"object": {
"termType": "BlankNode",
"termType": "Variable",
"value": "g_0"
},
"graph": {
Expand Down Expand Up @@ -115,4 +115,4 @@
"value": "s"
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"type": "pattern",
"termType": "Quad",
"subject": {
"termType": "BlankNode",
"termType": "Variable",
"value": "g_0"
},
"predicate": {
Expand Down Expand Up @@ -110,4 +110,4 @@
]
},
"variables": []
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"type": "pattern",
"termType": "Quad",
"subject": {
"termType": "BlankNode",
"termType": "Variable",
"value": "e_a"
},
"predicate": {
Expand Down Expand Up @@ -46,4 +46,4 @@
]
},
"variables": []
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"value": "http://example.com/ns#p"
},
"object": {
"termType": "BlankNode",
"termType": "Variable",
"value": "e_a"
},
"graph": {
Expand Down Expand Up @@ -46,4 +46,4 @@
]
},
"variables": []
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
"type": "pattern",
"termType": "Quad",
"subject": {
"termType": "BlankNode",
"termType": "Variable",
"value": "g_0"
},
"predicate": {
"termType": "NamedNode",
"value": "http://example.com/ns#p"
},
"object": {
"termType": "BlankNode",
"termType": "Variable",
"value": "g_1"
},
"graph": {
Expand All @@ -42,4 +42,4 @@
]
},
"variables": []
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"value": "http://example.com/ns#b"
},
"object": {
"termType": "BlankNode",
"termType": "Variable",
"value": "g_0"
},
"graph": {
Expand All @@ -121,7 +121,7 @@
"type": "pattern",
"termType": "Quad",
"subject": {
"termType": "BlankNode",
"termType": "Variable",
"value": "g_1"
},
"predicate": {
Expand Down Expand Up @@ -153,7 +153,7 @@
"value": "http://example.com/ns#b"
},
"object": {
"termType": "BlankNode",
"termType": "Variable",
"value": "g_2"
},
"graph": {
Expand Down Expand Up @@ -183,4 +183,4 @@
"value": "R"
}
]
}
}

0 comments on commit 0840757

Please sign in to comment.