Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#675 - Add uuid() function to MySqlModule #688

Merged
merged 2 commits into from
May 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -39,6 +39,6 @@ trait MysqlSqlModule extends Sql { self =>
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")))
}

}
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("rand") {
val query = select(Rand(5))

Expand Down