Uploaded image for project: 'Apache Jena'
  1. Apache Jena
  2. JENA-2361

TDB doesn't preserve lexical form of integer-valued decimals

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • Jena 5.1.0
    • None
    • TDB2
    • None

    Description

      The following sample code reproduces the issue:

       

      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());
          });
      }  

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

       

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              dobrist Damien Obrist
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: