1 and true (0 and false) are interpreted as the same by RDF4J provider/JDBC driver
Attempting to insert two statements with the same subject and property and object of value 1 with any numeric datatype and true via the RDF4J driver leads to just the first statement being inserted into the repository.
Hopefully the following code reproducing the issue makes the description more understandable:
Repository repository = new VirtuosoRepository("jdbc:virtuoso://localhost:1111/log_enable=1", "dba", "dba");
try {
IRI subj = Values.iri("http://example.com/subject");
IRI property = Values.iri("http://example.com/property");
ValueFactory vf = repository.getValueFactory();
try (RepositoryConnection conn = repository.getConnection()) {
conn.begin();
List<Statement> statements = List.of(vf.createStatement(subj, property, vf.createLiteral("1", XSD.INT)),
vf.createStatement(subj, property, vf.createLiteral("true", XSD.BOOLEAN))
);
conn.add(statements);
conn.commit();
}
try (RepositoryConnection conn = repository.getConnection()) {
List<Statement> result = conn.getStatements(subj, null, null, false).stream().toList();
assertEquals(2, result.size()); // This fails, there is only one result statement
}
} finally {
repository.shutDown();
}
The assertion fails as the repository contains only one statement - the first one. From my debugging it seems the problem goes into the JDBC driver (tested with virtjdbc4_3 version 3.123) or even into the way Virtuoso server interprets the prepared statement parameters it receives.
The following table illustrates which value combinations I tried and what results I got in terms of correctness of data in the repository.
| Value one | Value two | Correct? |
|---|---|---|
1 |
true |
NO |
1.0 |
true |
NO |
1.1 |
true |
YES |
1 |
false |
YES |
0 |
false |
NO |
0.0 |
false |
NO |
0.1 |
false |
YES |
I tested various datatypes numeric datatypes (xsd:int, xsd:integer, xsd:long, xsd:double) for value one and xsd:boolean for value two, but the gist seems to be that 1 is interpreted as true and 0 as false. Any value other than 1 (or 0 for false) work correctly.
Virtuoso version: 07.20.3240, running in Docker container. RDF4J 5.1 provider version: 1.20 JDBC 4.3 driver version: 3.123
It looks a server side issue