Skip to content

Commit

Permalink
zio#657 - Add uuid() function to MySqlModule
Browse files Browse the repository at this point in the history
  • Loading branch information
vidyasankarv committed May 26, 2022
1 parent be1f30a commit a15889e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mysql/src/main/scala/zio/sql/mysql/MysqlSqlModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
Expand All @@ -21,7 +22,6 @@ trait MysqlSqlModule extends Sql { self =>
r => Right(r)
)
}

}
}

Expand All @@ -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")))
}

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

0 comments on commit a15889e

Please sign in to comment.