Skip to content

Commit

Permalink
Add hex function to MySql module (#676)
Browse files Browse the repository at this point in the history
* Added hex function #659

* lint

* 659 updated argument to Long
  • Loading branch information
ujali authored May 26, 2022
1 parent 223ada3 commit 7aa0ea8
Show file tree
Hide file tree
Showing 2 changed files with 8 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 @@ -31,6 +31,7 @@ trait MysqlSqlModule extends Sql { self =>
val CurrentDate = Expr.ParenlessFunctionCall0[LocalDate](FunctionName("current_date"))
val CurrentTime = Expr.ParenlessFunctionCall0[OffsetTime](FunctionName("current_time"))
val Degrees = FunctionDef[Double, Double](FunctionName("degrees"))
val Hex = FunctionDef[Long, String](FunctionName("hex"))
val Log2 = FunctionDef[Double, Double](FunctionName("log2"))
val Log10 = FunctionDef[Double, Double](FunctionName("log10"))
val MakeTime = FunctionDef[(Int, Int, Double), LocalTime](FunctionName("maketime"))
Expand Down
7 changes: 7 additions & 0 deletions mysql/src/test/scala/zio/sql/mysql/FunctionDefSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ object FunctionDefSpec extends MysqlRunnableSpec with ShopSchema {

assertion.mapErrorCause(cause => Cause.stackless(cause.untraced))
},
test("hex") {
val query = select(Hex(255L)) from customers
val expected = "FF"
val queryResult = execute(query)

assertZIO(queryResult.runHead.some)(equalTo(expected))
},
test("log2") {
val query = select(Log2(8d)) from customers

Expand Down

0 comments on commit 7aa0ea8

Please sign in to comment.