We're updating the issue view to help you get more done. 

Sparql query parser creates value constants with equal names for different literals

Description

The issue can easily be reproduced by executing an update like:

1 2 3 4 INSERT DATA { <urn:1> <urn:label> "test" . <urn:2> <urn:label> "test"@bg . }

instead of inserting those two statements, we end up with

1 2 <urn:1> <urn:label> "test" . <urn:2> <urn:label> "test" .

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)
...

1 Var var = createAnonVar("-const-" + value.stringValue());

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:

1 select * {?s ?p \"test\" , \"test\"@bg .}
1 2 3 4 5 6 7 8 9 10 11 12 13 Projection ProjectionElemList ProjectionElem "s" ProjectionElem "p" Join StatementPattern Var (name=s) Var (name=p) Var (name=-const-test, value="test", anonymous) StatementPattern Var (name=s) Var (name=p) Var (name=-const-test, value="test"@bg, anonymous)

Environment

None

Status

Assignee

JeenB

Reporter

Damyan Ognyanov

Labels

None

Components

Fix versions

Affects versions

2.7.6

Priority

Critical