Skip to content

Commit

Permalink
Merge branch 'master' into zio#675
Browse files Browse the repository at this point in the history
  • Loading branch information
sviezypan authored May 26, 2022
2 parents a15889e + 33a9e27 commit e56958b
Show file tree
Hide file tree
Showing 2 changed files with 8 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 Rand = FunctionDef[Int, Double](FunctionName("rand"))
val RPad = FunctionDef[(String, Int, String), String](FunctionName("rpad"))
val Uuid = Expr.FunctionCall0[UUID](FunctionDef[Any, UUID](FunctionName("uuid")))
}
Expand Down
7 changes: 7 additions & 0 deletions mysql/src/test/scala/zio/sql/mysql/FunctionDefSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@ object FunctionDefSpec extends MysqlRunnableSpec with ShopSchema {
test("uuid") {
assertZIO(execute(select(Uuid)).runHead.some)(!isNull)
},
test("rand") {
val query = select(Rand(5))

val testResult = execute(query)

assertZIO(testResult.runHead.some)(isGreaterThanEqualTo(0d) && isLessThanEqualTo(1d))
},
test("rpad") {
val cases = Seq(("hi", 5, "?", "hi???"), ("hi", 1, "?", "h"))
check(Gen.fromIterable(cases)) { case (str, len, pad, exp) =>
Expand Down

0 comments on commit e56958b

Please sign in to comment.