Uploaded image for project: 'Jackrabbit Oak'
  1. Jackrabbit Oak
  2. OAK-10033

Conditions on dates use the wrong range

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.48.0
    • None
    • None

    Description

      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.

      [calendar@startTime] <> cast('1971-01-01T13:00:00.000Z' AS date)
      +calendar@startTime:[0 TO 9223372036854775807] -calendar@startTime:[31582800000 TO 31582800000]

      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

      // not null. For date lower bound of zero can be used
      return NumericRangeQuery.newLongRange(propertyName, 0L, Long.MAX_VALUE, true, true);

      This isn't correct, as 0 means 1970-01-01T00:00:00.000Z

      It should probably be :

      // not null. For date lower bound of zero can be used
      return NumericRangeQuery.newLongRange(propertyName, Long.MIN_VALUE, Long.MAX_VALUE, true, true);

      Attachments

        Issue Links

          Activity

            People

              mkataria Mohit Kataria
              mkataria Mohit Kataria
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: