You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@jena.apache.org by "ting668 (via GitHub)" <gi...@apache.org> on 2026/09/20 02:12:11 UTC
[I] Duration equality rejects `"P0Y1D"^^xsd:duration` as unequal to `"P1D"^^xsd:dayTimeDuration` [jena]
ting668 opened a new issue, #4236:
URL: https://github.com/apache/jena/issues/4236
### Version
6.2.0
### What happened?
**Reporter:** ting668
## Environment
- Apache Jena Version: `6.2.0`
- Java Version: `21.0.12+8-LTS`
## Description
While testing Apache Jena using a method based on attribute-constraint analysis, I found that duration equality misses a value that should compare equal: `"P0Y1D"^^xsd:duration` (zero years plus one day) is not accepted as equal to `"P1D"^^xsd:dayTimeDuration` (one day).
Comparing duration values component by component, both `P0Y1D` and `P1D` are zero months plus one day and therefore equal, while `P2D` (two days) is not equal to `P1D`.
## How to Reproduce and Expected Behavior
**Note:** The queries below are a **minimized, simplified example** reproducing the bug.
Buggy query (with the default graph loaded with the N-Triples data below):
```sparql
SELECT ?s WHERE { ?s <urn:pub:p> ?v . FILTER(?v = "P1D"^^<http://www.w3.org/2001/XMLSchema#dayTimeDuration>) } ORDER BY ?s
```
Data (default graph, N-Triples):
```nt
<urn:pub:zeroField> <urn:pub:p> "P0Y1D"^^<http://www.w3.org/2001/XMLSchema#duration> .
<urn:pub:oneDay> <urn:pub:p> "P1D"^^<http://www.w3.org/2001/XMLSchema#dayTimeDuration> .
<urn:pub:twoDays> <urn:pub:p> "P2D"^^<http://www.w3.org/2001/XMLSchema#dayTimeDuration> .
<urn:pub:background> <urn:pub:other> <urn:pub:value> .
```
Expected behavior: `P0Y1D` and `P1D` are both one-day durations, so both rows match (in `ORDER BY ?s` order):
```text
[{"s":"<urn:pub:oneDay>"},{"s":"<urn:pub:zeroField>"}]
```
Actual behavior: only the row carrying `"P1D"^^xsd:dayTimeDuration` is returned; the row carrying `"P0Y1D"^^xsd:duration` is missed:
```text
[{"s":"<urn:pub:oneDay>"}]
```
This suggests that duration equality does not determine the value of a duration from its numeric components: the explicitly zero year field of the `xsd:duration` value prevents it from matching the equal `xsd:dayTimeDuration` constant, so a row that should match the filter is dropped.
### Relevant output and stacktrace
```shell
```
### Are you interested in making a pull request?
None
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org