Skip to content

Commit

Permalink
Added Radians Function to MySQL module (#689)
Browse files Browse the repository at this point in the history
  • Loading branch information
walesho authored May 26, 2022
1 parent 9b6b455 commit a8b84e9
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 @@ -40,5 +40,6 @@ trait MysqlSqlModule extends Sql { self =>
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")))
val Radians = FunctionDef[Double, Double](FunctionName("radians"))
}
}
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 @@ -169,6 +169,15 @@ object FunctionDefSpec extends MysqlRunnableSpec with ShopSchema {
execute(select(CurrentTime)).runHead.some
.map(t => DateTimeFormatter.ofPattern("HH:mm:ss").format(t))
)(matchesRegex("(2[0-3]|[01][0-9]):[0-5][0-9]:[0-5][0-9]"))
},
test("Radians") {
val query = select(Radians(40d))

val expected = Math.toRadians(40d)

val testResult = execute(query)

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

0 comments on commit a8b84e9

Please sign in to comment.