Skip to content

Commit

Permalink
Merge pull request #677 from bburdiliak/gen_random_uuid-for-postgresql
Browse files Browse the repository at this point in the history
support for gen_random_uuid function of PostgreSQL
  • Loading branch information
sviezypan authored May 26, 2022
2 parents a5f5c40 + 55ba7f6 commit 8857470
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import java.sql.ResultSet
import java.text.DecimalFormat
import java.time._
import java.time.format.DateTimeFormatter
import java.util.Calendar

import java.util.{ Calendar, UUID }
import org.postgresql.util.PGInterval
import zio.Chunk
import zio.sql.Sql
Expand Down Expand Up @@ -308,6 +307,7 @@ trait PostgresSqlModule extends Sql { self =>
val SetSeed = FunctionDef[Double, Unit](FunctionName("setseed"))
val BitLength = FunctionDef[String, Int](FunctionName("bit_length"))
val Pi = Expr.FunctionCall0[Double](FunctionDef[Any, Double](FunctionName("pi")))
val GenRandomUuid = Expr.FunctionCall0[UUID](FunctionDef[Any, UUID](FunctionName("gen_random_uuid")))
}

}
11 changes: 11 additions & 0 deletions postgres/src/test/scala/zio/sql/postgresql/FunctionDefSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,17 @@ object FunctionDefSpec extends PostgresRunnableSpec with DbSchema {

assertion.mapErrorCause(cause => Cause.stackless(cause.untraced))
},
test("gen_random_uuid") {
val query = select(GenRandomUuid)

val testResult = execute(query)

val assertion = for {
r <- testResult.runCollect
} yield assert(r.head)(!isNull)

assertion.mapErrorCause(cause => Cause.stackless(cause.untraced))
},
suite("format function")(
test("format0") {
import Expr._
Expand Down

0 comments on commit 8857470

Please sign in to comment.