Damien Obrist created JENA-2361:
-----------------------------------
Summary: TDB doesn't preserve lexical form of integer-valued
decimals
Key: JENA-2361
URL: https://issues.apache.org/jira/browse/JENA-2361
Project: Apache Jena
Issue Type: Bug
Components: TDB2
Affects Versions: Jena 5.1.0
Reporter: Damien Obrist
The following sample code reproduces the issue:
{code:java}
public static void main(String[] arguments) {
try {
FileUtils.deleteDirectory(new File("sample-data"));
} catch (IOException e) {
throw new RuntimeException(e);
}
Dataset dataset = TDB2Factory.connectDataset("sample-data");
Txn.executeWrite(dataset, () -> {
// TDB: code wrongly prints out "2.0"
Model model = dataset.getDefaultModel();
// in-memory: code correctly prints out "2"
//Model model = ModelFactory.createDefaultModel();
model.add(
ResourceFactory.createResource("http://www.test.com/my-graph"),
RDF.type,
ResourceFactory.createTypedLiteral("2", XSDDatatype.XSDdecimal)
);
System.out.println(model.listStatements().next().getObject().asLiteral().getLexicalForm());
});
} {code}
The behaviour is as follows:
* When running the code with Jena 5.1.0, it wrongly prints out "2.0"
* When running the code with Jena 5.0.0, it correctly prints out "2"
* When running the code using the in-memory model instead of the TDB one, then
with both Jena 5.0.0 and 5.1.0, it correctly prints out "2"
It seems that the problem happens when writing the triple, not when reading it:
if the above code is modified and run with Jena 5.0.0 to store, and with Jena
5.1.0 to read the triple, then it correctly prints out "2".
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]