You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-issues@jackrabbit.apache.org by "Mohit Kataria (Jira)" <ji...@apache.org> on 2022/12/16 08:49:00 UTC

[jira] [Created] (OAK-10033) Conditions on dates use the wrong range

Mohit Kataria created OAK-10033:
-----------------------------------

             Summary: Conditions on dates use the wrong range
                 Key: OAK-10033
                 URL: https://issues.apache.org/jira/browse/OAK-10033
             Project: Jackrabbit Oak
          Issue Type: Bug
            Reporter: Mohit Kataria
            Assignee: Mohit Kataria


For queries like:
SELECT * FROM [nt:base] AS main WHERE  (main.[startTime] <> cast('1971-01-01T13:00:00.000Z' AS date))
The condition uses the wrong range, as negative values are possible. The range should be -9223372036854775808 TO 9223372036854775807 and not 0 TO 9223372036854775807.
{code:java}
[calendar@startTime] <> cast('1971-01-01T13:00:00.000Z' AS date)
+calendar@startTime:[0 TO 9223372036854775807] -calendar@startTime:[31582800000 TO 31582800000]{code}
Source code:
[https://github.com/apache/jackrabbit-oak/blob/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyValueImpl.java]

[https://github.com/apache/jackrabbit-oak/blob/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java#L1227]
{code:java}
// not null. For date lower bound of zero can be used
return NumericRangeQuery.newLongRange(propertyName, 0L, Long.MAX_VALUE, true, true);{code}
This isn't correct, as 0 means 1970-01-01T00:00:00.000Z

It should probably be :
{code:java}
// not null. For date lower bound of zero can be used
return NumericRangeQuery.newLongRange(propertyName, Long.MIN_VALUE, Long.MAX_VALUE, true, true);{code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)