Skip to content

Commit

Permalink
#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 148b9b5
Show file tree
Hide file tree
Showing 2 changed files with 7 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")))
}

}
5 changes: 5 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,11 @@ object FunctionDefSpec extends MysqlRunnableSpec with ShopSchema {

assertZIO(testResult.runHead.some)(equalTo(expected))
},
test("uuid") {
val query = select(Uuid)
val testResult = execute(query)
assertZIO(testResult.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 148b9b5

Please sign in to comment.