HolgerKnublauch opened a new issue, #3267:
URL: https://github.com/apache/jena/issues/3267

   ### 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.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;
   import org.topbraid.jenax.util.ARQFactory;
   
   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 = ARQFactory.get().getDataset(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
   
   ```shell
   
   ```
   
   ### Are you interested in making a pull request?
   
   None


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to