jnosql icon indicating copy to clipboard operation
jnosql copied to clipboard

Support `special_expression` keywords (e.g., `LOCAL DATE`, `TRUE`, `FALSE`) in Eclipse JNoSQL query processing for `select`, `update`, and `delete`

Open otaviojava opened this issue 3 months ago • 1 comments

Eclipse JNoSQL should support the special_expression rule defined in the Jakarta Query grammar, which includes special constants such as:

  • LOCAL DATE
  • LOCAL TIME
  • LOCAL DATETIME
  • TRUE
  • FALSE

These expressions must be supported consistently across all query operations:

  • select
  • update
  • delete

🤝 Specification Alignment

This enhancement ensures Eclipse JNoSQL remains compatible with Jakarta Query, and by extension, with Jakarta NoSQL and Jakarta Persistence that use this grammar.

🔁 Mapping Table

Jakarta Query Syntax Java Type Java Equivalent
LOCAL DATE java.time.LocalDate LocalDate.now()
LOCAL TIME java.time.LocalTime LocalTime.now()
LOCAL DATETIME java.time.LocalDateTime LocalDateTime.now()
TRUE boolean / Boolean true
FALSE boolean / Boolean false

1. Select query

template.query("from Event where scheduledAt >= LOCAL DATE and active = TRUE", Event.class)
        .result();

2. Update query

template.query("update Event set active = FALSE where scheduledAt < LOCAL DATETIME", Event.class)
        .executeUpdate();

3. Delete query

template.query("delete from Event where active = FALSE", Event.class)
        .executeDelete();
  • ❌ Parse and resolve LOCAL DATE, LOCAL TIME, and LOCAL DATETIME into java.time instances at query runtime.

  • [ ] Parse and resolve TRUE and FALSE into boolean values.

  • [ ] Ensure this works for:

    • [ ] select queries
    • [ ] update queries
    • [ ] delete queries
  • [ ] Add internal tests for all combinations.

  • [ ] Add documentation examples.

otaviojava avatar Sep 15 '25 17:09 otaviojava

@dearrudam this we have the same issue with LOCAL and date operations.

It won't support those by default on mongodb, thus, I will work only on the true and false operator

otaviojava avatar Sep 29 '25 17:09 otaviojava

@otaviojava, correct me if I'm wrong but or if I didn't get the core idea but, I think that we could define the local date operation during the translate query process to the MongoDB. For exemple:

template.query("from Event where scheduledAt >= LOCAL DATE and active = TRUE", Event.class)
        .result();

It would be converted in runtime to something limilar to the code below:

db.Event.find({
  scheduledAt: {
    $gte: ISODate("2025-12-15T01:00:00+03:00")
  },
  active: true
})

dearrudam avatar Dec 15 '25 04:12 dearrudam

@dearrudam, it could, but we need to define how to translate this expression on the communication layer.

The first question would be more if it makes sense to do this kind of change right now.

otaviojava avatar Dec 15 '25 07:12 otaviojava

Maybe, find the function expression as spec and then start implementing here.

otaviojava avatar Dec 15 '25 07:12 otaviojava