Uploaded image for project: 'Spring Data MongoDB'
  1. Spring Data MongoDB
  2. DATAMONGO-2499

Combining two operators in a not operator

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Investigating
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Core
    • Sprint:
      Neumann RC1, 2020.0.0 - Ockham M1, 2020.0.0 - Ockham RC2

      Description

      In trying to recreate this mongo db query:

      {
        "createdOn": {
          $not: {
            "$lte": ISODate("2020-20-23T23:59:59.999999999"),
            "$gte": ISODate("2020-20-23T00:00"),
          }
        }
      }
      

      with either of the following:

      Criteria.where("createdOn")
          .not()
          .gte(LocalDate.now().atTime(LocalTime.MIN))
          .lte(LocalDate.now().atTime(LocalTime.MAX)) 
      Criteria.where("createdOn")
          .not()
          .gte(LocalDate.now().atTime(LocalTime.MIN))
          .not()
          .lte(LocalDate.now().atTime(LocalTime.MAX))
      

      I get the following generated output:

      {
        "createdOn": {
          "$not": {
            "$gte": {
              "$java": "2020-03-23T00:00"
            }
          },
          "$lte": {
            "$java": "2020-03-23T23:59:59.999999999"
          }
        }
      }

      I've managed to re-do my query using an or operator (thanks to someone on stack overflow), but I feel like I should still be able to produce the above shell code with using the Criteria builder.

       

        Attachments

          Activity

            People

            Assignee:
            cstrobl Christoph Strobl
            Reporter:
            lavoaster Lavoaster
            Last updater:
            Christoph Strobl
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: