Skip to content

Commit

Permalink
Add the 'rpad' function to the MysqlSqlModule (#682)
Browse files Browse the repository at this point in the history
* Add the 'rpad' function to the MysqlSqlModule

* fix merge mistake
  • Loading branch information
amrkamel authored May 26, 2022
1 parent 7aa0ea8 commit 61dc2e8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions mysql/src/main/scala/zio/sql/mysql/MysqlSqlModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}

}
6 changes: 6 additions & 0 deletions mysql/src/test/scala/zio/sql/mysql/FunctionDefSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 61dc2e8

Please sign in to comment.