Skip to content

Combining two operators in a not operator [DATAMONGO-2499] #3355

Open
@spring-projects-issues

Description

@spring-projects-issues

Lavoaster opened DATAMONGO-2499 and commented

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.

 


No further details from DATAMONGO-2499

Metadata

Metadata

Labels

in: coreIssues in core supporttype: bugA general bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions