Skip to content

Commit

Permalink
Merge pull request #671 from peixunzhang/655
Browse files Browse the repository at this point in the history
Add makedate function to MysqlSqlModule #655
  • Loading branch information
sviezypan authored May 27, 2022
2 parents 7b5afc9 + 342d303 commit cec08b3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions mysql/src/main/scala/zio/sql/mysql/MysqlSqlModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ trait MysqlSqlModule extends Sql { self =>
val Hex = FunctionDef[Long, String](FunctionName("hex"))
val Log2 = FunctionDef[Double, Double](FunctionName("log2"))
val Log10 = FunctionDef[Double, Double](FunctionName("log10"))
val MakeDate = FunctionDef[(Int, Int), LocalDate](FunctionName("makedate"))
val MakeTime = FunctionDef[(Int, Int, Double), LocalTime](FunctionName("maketime"))
val Now = FunctionDef[Any, ZonedDateTime](FunctionName("now"))
val Pi = Expr.FunctionCall0[Double](FunctionDef[Any, Double](FunctionName("pi")))
Expand Down
9 changes: 9 additions & 0 deletions mysql/src/test/scala/zio/sql/mysql/FunctionDefSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,15 @@ object FunctionDefSpec extends MysqlRunnableSpec with ShopSchema {

val testResult = execute(query)

assertZIO(testResult.runHead.some)(equalTo(expected))
},
test("makedate") {
val query = select(MakeDate(2022, 31)) from customers

val expected = LocalDate.of(2022, 1, 31)

val testResult = execute(query)

assertZIO(testResult.runHead.some)(equalTo(expected))
}
)
Expand Down

0 comments on commit cec08b3

Please sign in to comment.