The issue can easily be reproduced by executing an update like:
instead of inserting those two statements, we end up with
It seems related to the work around SES-1922. I've narrowed it down to
the implementation of org.openrdf.query.parser.sparql.TupleExprBuilder.createConstVar(Value)
in case when an instance of LiteralImpl is passed, the stringValue() will return its label and the name of the new var will be "-const-test", no matter that both "test" and "test"@bg are different.
As a result, later when processing both statementPatterns from the "insert data" the actual value will be resolved using the "-const-test" and we will end up with such wrong being put into the repository.
Could suggest to use value.toString() instead of value.stringValue() within the above code fragment so to avoid the issue (of course if the difference within BNodeImpl.stringValue() & toString() is not causing some unforeseen side effects)
One may also can reproduce it by looking at the generated query model for: