diff --git a/mysql/src/main/scala/zio/sql/mysql/MysqlSqlModule.scala b/mysql/src/main/scala/zio/sql/mysql/MysqlSqlModule.scala index 162c73574..cc8db34e4 100644 --- a/mysql/src/main/scala/zio/sql/mysql/MysqlSqlModule.scala +++ b/mysql/src/main/scala/zio/sql/mysql/MysqlSqlModule.scala @@ -37,6 +37,7 @@ trait MysqlSqlModule extends Sql { self => val MakeTime = FunctionDef[(Int, Int, Double), LocalTime](FunctionName("maketime")) val Now = FunctionDef[Any, ZonedDateTime](FunctionName("now")) val Pi = Expr.FunctionCall0[Double](FunctionDef[Any, Double](FunctionName("pi"))) + val RPad = FunctionDef[(String, Int, String), String](FunctionName("rpad")) } } diff --git a/mysql/src/test/scala/zio/sql/mysql/FunctionDefSpec.scala b/mysql/src/test/scala/zio/sql/mysql/FunctionDefSpec.scala index 0d76ed157..4da50d13d 100644 --- a/mysql/src/test/scala/zio/sql/mysql/FunctionDefSpec.scala +++ b/mysql/src/test/scala/zio/sql/mysql/FunctionDefSpec.scala @@ -198,6 +198,12 @@ object FunctionDefSpec extends MysqlRunnableSpec with ShopSchema { assertion.mapErrorCause(cause => Cause.stackless(cause.untraced)) }, + test("rpad") { + val cases = Seq(("hi", 5, "?", "hi???"), ("hi", 1, "?", "h")) + check(Gen.fromIterable(cases)) { case (str, len, pad, exp) => + assertZIO(execute(select(RPad(str, len, pad))).runHead.some)(equalTo(exp)) + } + }, test("current_time") { assertZIO( execute(select(CurrentTime)).runHead.some