Skip to content

Dates in queries are logged with $date and not ISODate #5116

@WildDev

Description

@WildDev

I have downloaded a basic template from start.spring.io with the only dependencies spring-boot-starter-webflux and spring-boot-starter-data-mongodb-reactive to reproduce some weird behavior of the ReactiveMongoTemplate regarding the dates.

A basic query findByAddedBefore(Instant value) transpiles into a wrong query:
ReactiveMongoTemplate : find using query: { "added" : { "$lt" : { "$date" : "2025-12-09T23:53:38.977Z"}}} fields: Document{{}} for class: class com.example.demo.Buck in collection: buckets

While it would work correctly if it was instead:
{ "added" : { "$lt" : ISODate("2025-12-09T23:53:38.977Z") }}

I have also tested it with Date, LocalDateTime, OffsetDateTime, but still neither of them works.

buckets.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions