Panache Query With Mongo: and operator not working properly with multiple conditions on same field #12086
Open
Description
The following test is failing:
@Test
public void failingQuery() {
UUID videoId = UUID.randomUUID();
LocalDateTime now = LocalDateTime.now();
View view = new View(videoId, now.minusMinutes(10));
view.persist();
long count1 = View.count("createdAt > ?1", now.minusMinutes(2));
logger.info("count 1: {}", count1);
assertThat(count1).isEqualTo(0); // passing
long count2 = View.count("createdAt > ?1 and createdAt < ?2", now.minusMinutes(2), now);
logger.info("count 2: {}", count2);
assertThat(count2).isEqualTo(0); // failing (count2 is equal to 1)
}
I think the corresponding mongo query should be
createdAt: {
$gte: ISODate(date1),
$lt: ISODate(date2)
}
The actual mongo query created by panache is:
{
'createdAt':{'$gt':ISODate('2020-09-14T18:49:36.897Z')},
'createdAt':{'$lt':ISODate('2020-09-14T18:51:36.897Z')}
}