Skip to content

Return incorrect results when query integer numbers #3801

@uniqueR-7

Description

@uniqueR-7

Current Behavior

Write the number 5 of unspecified data type, int type, and long type to the database.

The Java code which writes the numbers to the database is:

Repository db = new SailRepository(new MemoryStore());
IRI john = Values.iri("http://JohnSmith");
IRI mark = Values.iri("http://Mark");
IRI peter = Values.iri("http://Peter");

try (RepositoryConnection conn = db.getConnection()) {
	conn.add(john, FOAF.AGE, Values.literal(5));
	conn.add(mark, FOAF.AGE, Values.literal(String.valueOf(5), XSD.INT));
	conn.add(peter, FOAF.AGE, Values.literal(String.valueOf(5), XSD.LONG));
}

Then query the database for the statement whose literal value is 5.

The SparQL query statement is:

SELECT *
WHERE { ?s ?p 5. }

The query result is empty, instead of the three number 5 in the database.

Expected Behavior

The expected query result is:

?s ?p
<http://JohnSmith> <http://xmlns.com/foaf/0.1/age>
<http://Mark> <http://xmlns.com/foaf/0.1/age>
<http://Peter> <http://xmlns.com/foaf/0.1/age>

Steps To Reproduce

  1. Write the following Java code to write the numbers to the database:

    Repository db = new SailRepository(new MemoryStore());
    IRI john = Values.iri("http://JohnSmith");
    IRI mark = Values.iri("http://Mark");
    IRI peter = Values.iri("http://Peter");
    
    try (RepositoryConnection conn = db.getConnection()) {
    	conn.add(john, FOAF.AGE, Values.literal(5));
    	conn.add(mark, FOAF.AGE, Values.literal(String.valueOf(5), XSD.INT));
    	conn.add(peter, FOAF.AGE, Values.literal(String.valueOf(5), XSD.LONG));
    }
  2. Execute the following query:

    SELECT *
    WHERE { ?s ?p 5. }
    

    The corresponding Java code is:

    try (RepositoryConnection conn = db.getConnection()) {
    	String queryString = "SELECT * WHERE { ?s ?p 5. }";
    	TupleQuery query = conn.prepareTupleQuery(queryString);
    	TupleQueryResultHandler tsvWriter = new SPARQLResultsTSVWriter(System.out);
    	query.evaluate(tsvWriter);
    }

Version

4.0.0-M1

Are you interested in contributing a solution yourself?

No response

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions