orangy / squash

SQL access DSL for Kotlin
265 stars 16 forks source link

MySQL Dialect : Support Basic Date Part and Date Math Functions #32

Closed codesplode closed 5 years ago

codesplode commented 5 years ago

Note

I re-issued this pull request as improvements were made to allow Expression in dateAdd and dateSub (to use columns or literal values) in the arithmetic.

Dependencies

This feature does require the GeneralFunctionExpression implementation from my previous pull request, though could be reworked easily as necessary. Merging this essentially means merging that request as well. I'm happy to resubmit this request later after the previous one is pulled if that makes the history cleaner / clearer.

Description

Adds support for the following MySQL specific functions:

Most database have very similar functions that could be quickly implemented using this as an example. This does also include a basic implementation of MySQL's INTERVAL syntax and values, using Java's ChronoUnit to generically translate. There are additional, more unique definitions for these for combined units (ex: MINUTE_SECOND), that could be added in the future as well. See: MySQL Temporal Intervals