diff --git a/mysql/src/main/scala/zio/sql/mysql/MysqlSqlModule.scala b/mysql/src/main/scala/zio/sql/mysql/MysqlSqlModule.scala index cc8db34e4..158f6d284 100644 --- a/mysql/src/main/scala/zio/sql/mysql/MysqlSqlModule.scala +++ b/mysql/src/main/scala/zio/sql/mysql/MysqlSqlModule.scala @@ -2,6 +2,7 @@ package zio.sql.mysql import java.sql.ResultSet import java.time.{ LocalDate, LocalTime, OffsetTime, Year, ZonedDateTime } +import java.util.UUID import zio.sql.Sql trait MysqlSqlModule extends Sql { self => @@ -21,7 +22,6 @@ trait MysqlSqlModule extends Sql { self => r => Right(r) ) } - } } @@ -38,6 +38,6 @@ trait MysqlSqlModule extends Sql { self => 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")) + val Uuid = Expr.FunctionCall0[UUID](FunctionDef[Any, UUID](FunctionName("uuid"))) } - } diff --git a/mysql/src/test/scala/zio/sql/mysql/FunctionDefSpec.scala b/mysql/src/test/scala/zio/sql/mysql/FunctionDefSpec.scala index 6bcc24e5c..d01eef2ce 100644 --- a/mysql/src/test/scala/zio/sql/mysql/FunctionDefSpec.scala +++ b/mysql/src/test/scala/zio/sql/mysql/FunctionDefSpec.scala @@ -148,6 +148,9 @@ object FunctionDefSpec extends MysqlRunnableSpec with ShopSchema { assertZIO(testResult.runHead.some)(equalTo(expected)) }, + test("uuid") { + assertZIO(execute(select(Uuid)).runHead.some)(!isNull) + }, test("rpad") { val cases = Seq(("hi", 5, "?", "hi???"), ("hi", 1, "?", "h")) check(Gen.fromIterable(cases)) { case (str, len, pad, exp) =>