Skip to content

Commit

Permalink
Merge branch 'master' into postgres-functions-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sviezypan authored May 31, 2022
2 parents edd7e60 + fa86aca commit 473d039
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 7 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ Connection pool | :white_check_mark:

Feature | PostgreSQL | SQL Server | Oracle | MySQL
:------------ | :-------------| :-------------|:-------------------| :-------------
Render Read | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
Render Read | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
Render Delete | :heavy_check_mark: | :heavy_check_mark: | :white_check_mark: | :white_check_mark: |
Render Update | :heavy_check_mark: | | :white_check_mark: | :white_check_mark: |
Render Insert | :heavy_check_mark: | | |
Render Update | :heavy_check_mark: | | :white_check_mark: | :white_check_mark: |
Render Insert | :heavy_check_mark: | | | :white_check_mark: |
Functions | :heavy_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
Types | :white_check_mark: | | | :white_check_mark: |
Operators | | | |
Types | :white_check_mark: | | | :white_check_mark: |
Operators | | | | |

## What is ZIO SQL?
ZIO SQL lets you write type-safe, type-inferred, and composable SQL queries in ordinary Scala, helping you prevent persistence bugs before they happen, and leverage your IDE to make writing SQL productive, safe, and fun.
Expand Down
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ lazy val jdbc = project
libraryDependencies ++= Seq(
"dev.zio" %% "zio-test" % zioVersion % Test,
"dev.zio" %% "zio-test-sbt" % zioVersion % Test,
"org.postgresql" % "postgresql" % "42.3.5" % Test,
"org.postgresql" % "postgresql" % "42.3.6" % Test,
"com.dimafeng" %% "testcontainers-scala-postgresql" % testcontainersScalaVersion % Test
)
)
Expand Down Expand Up @@ -203,7 +203,7 @@ lazy val postgres = project
"org.testcontainers" % "database-commons" % testcontainersVersion % Test,
"org.testcontainers" % "postgresql" % testcontainersVersion % Test,
"org.testcontainers" % "jdbc" % testcontainersVersion % Test,
"org.postgresql" % "postgresql" % "42.3.5" % Compile,
"org.postgresql" % "postgresql" % "42.3.6" % Compile,
"com.dimafeng" %% "testcontainers-scala-postgresql" % testcontainersScalaVersion % Test
)
)
Expand Down
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 @@ -41,6 +41,7 @@ trait MysqlSqlModule extends Sql { self =>
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")))
val Soundex = FunctionDef[String, String](FunctionName("soundex"))
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")))
Expand Down
32 changes: 32 additions & 0 deletions mysql/src/test/scala/zio/sql/mysql/FunctionDefSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,38 @@ object FunctionDefSpec extends MysqlRunnableSpec with ShopSchema {

assertZIO(testResult.runHead.some)(equalTo(expected))
},
test("soundex outputs should not match for non-similar-sounding strings") {
val queryForRobert = select(Soundex("Robert"))
val queryForTam = select(Soundex("Tam"))

val resultForRobert = execute(queryForRobert)
val resultForTam = execute(queryForTam)

for {
robertResult <- resultForRobert.runCollect
tamResult <- resultForTam.runCollect
} yield assert(robertResult.head.equals(tamResult.head))(equalTo(false))
},
test("soundex outputs should match for equivalent strings") {
val queryForRobert = select(Soundex("Robert"))
val queryForRupert = select(Soundex("Rupert"))

val resultForRobert = execute(queryForRobert)
val resultForRupert = execute(queryForRupert)

for {
robertResult <- resultForRobert.runCollect
rupertResult <- resultForRupert.runCollect
} yield assert(robertResult.head.equals(rupertResult.head))(equalTo(true))
},
test("soundex") {
val query = select(Soundex("Robert"))
val expected = "R163"

val testResult = execute(query)

assertZIO(testResult.runHead.some)(equalTo(expected))
},
test("current_date") {
val query = select(CurrentDate)

Expand Down

0 comments on commit 473d039

Please sign in to comment.