Version
5.4
What happened?
We are switching from initialBindings to substitution in preparation for initialBindings removal in Jena 6.
There is a difference in behavior that seems to be a show stopper for us. See the following test case. The expectation is that when I pass a blank node as binding, it should use exactly that blank node, but it seems to create a fresh blank node.
package org.topbraid.jenax.model;
import static org.junit.jupiter.api.Assertions.*;
import org.apache.jena.graph.Node;
import org.apache.jena.graph.NodeFactory;
import org.apache.jena.query.Dataset;
import org.apache.jena.query.DatasetFactory;
import org.apache.jena.query.Syntax;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.sparql.core.DatasetGraph;
import org.apache.jena.sparql.core.Var;
import org.apache.jena.sparql.engine.binding.Binding;
import org.apache.jena.sparql.engine.binding.BindingFactory;
import org.apache.jena.sparql.exec.UpdateExec;
import org.apache.jena.update.UpdateFactory;
import org.apache.jena.update.UpdateRequest;
import org.junit.jupiter.api.Test;
class SubstitutionBlankNodeTest {
@Test
void test() {
String updateString =
"PREFIX : <http://example.org/>\n" +
"INSERT { $node :p :o }\n" +
"WHERE { }\n";
UpdateRequest request = UpdateFactory.create(updateString, Syntax.syntaxARQ);
Model model = ModelFactory.createDefaultModel();
Dataset dataset = DatasetFactory.create(model);
DatasetGraph dsg = dataset.asDatasetGraph();
Node node = NodeFactory.createBlankNode();
Binding binding = BindingFactory.binding(Var.alloc("node"), node);
UpdateExec.newBuilder().
dataset(dsg).
update(request).
substitution(binding). // Fails
// initialBinding(binding). // Works
build().
execute();
int tripleCount = model.getGraph().find(node, Node.ANY, Node.ANY).toList().size();
assertEquals(tripleCount, 1);
}
}
Relevant output and stacktrace
Are you interested in making a pull request?
None
Version
5.4
What happened?
We are switching from initialBindings to substitution in preparation for initialBindings removal in Jena 6.
There is a difference in behavior that seems to be a show stopper for us. See the following test case. The expectation is that when I pass a blank node as binding, it should use exactly that blank node, but it seems to create a fresh blank node.
Relevant output and stacktrace
Are you interested in making a pull request?
None