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

2023-01-18 Thread Nitin Gupta (Jira)


[ 
https://issues.apache.org/jira/browse/OAK-10033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17678289#comment-17678289
 ] 

Nitin Gupta commented on OAK-10033:
---

trunk : 
[https://github.com/apache/jackrabbit-oak/commit/9d91389b6eaf1a0bb790204643b2ce03531fe624]
 

> 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
>Priority: Major
> Fix For: 1.48.0
>
>
> 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:[3158280 TO 3158280]{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)


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

2023-01-18 Thread Julian Reschke (Jira)


[ 
https://issues.apache.org/jira/browse/OAK-10033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17678245#comment-17678245
 ] 

Julian Reschke commented on OAK-10033:
--

[~mkataria] - should this be set to resolved???

> 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
>Priority: Major
>
> 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:[3158280 TO 3158280]{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)