zio/zio-sql

Add support for var-arg db functions

Opened this issue · 1 comments

Add support for var-arg db functions like format or concat.

@jczuchnowski can this implementation be a valid solution? (https://github.com/jgoday/zio-sql/tree/feature_variadic_args)

It would allow to call custom procedure/function with N different typed args.

val customFn = variadicFunc[String]("concat_ws")
val query    = select(customFn(", ", fName, lName)) from customers

A pending improvement could be to allow define variadicFunc with argument type parameters

val customFn = variadicFunc[String, Int, String]("custom_function")
val query    = select(customFn(name, id)) from table

but I can only imagine implementing this with macros ...