M5 functions

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

M5 functions

Andrus Adamchik
I finally started using M5 expression functions (the non-aggregating kind). It is a very good start. We can now build expressions with the following functions:

upper(..)
lower(..)
trim(..)
substring(..)
length(..)
locate(..)
abs(..)
sqrt(..)
mod(..)
concat(..)
CURRENT_DATE
CURRENT_TIME
CURRENT_TIMESTAMP

Some feedback from a few hours playing with it...

1. The list above miraculously works in LinkRest. Cool! (except for date/time functions ... because of #3)

2. The new functions are case insensitive when parsed from String. The rest of the expression syntax is traditionally case sensitive. I suggest that we align functions (both scalar and aggregate) with the prior behavior. Corollary to that - functions like CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP should be changed to camel case (currentDate, currentTime, currentTimestamp). And while we are at it, we need to add empty parenthesis to the no-arg function String definitions ("currentDate()", etc.), so that they look like functions, not paths and don't clash with property namespace. No parenthesis is a JPA approach, we have no reason to mirror it anymore.

3. Date/time functions are unparsable. From what I can tell "someDate < CURRENT_DATE" is not recognized by expression parser now and can only be created via the API.

4. We need more date/time functions. I realize this can be a pretty long list. Perhaps we start with date/time parts extraction functions that I personally find very common (based on java.time.LocalDateTime terminology):

* second(..)
* minute(..)
* hour(..)
* dayOfMonth(..)
* dayOfWeek(..)
* dayOfYear(..)
* month(..)
* year(..)

Andrus