orangy / squash

SQL access DSL for Kotlin
265 stars 16 forks source link

General Function Aggregates #26

Open codesplode opened 5 years ago

codesplode commented 5 years ago

Description

This feature intends to generalize the creation of common FunctionExpression implementations within dialects. It introduces a GeneralFunctionExpression class for functions that simply need a name and one value, which could be used by any dialects to quickly add functions, particularly aggregates.

As such, this pull request also includes the average() function as an addition to the BaseSQLDialect

Testing

Unit tests were added for the base aggregate functions, however, some adjustment was required to make it work generically for all databases as the types returned by the databases for an aggregate are not all the same. Some returned a Long vs a Double for the average() function for example.