Skip to content

Commit

Permalink
Merge branch 'master' into update/ojdbc8-21.7.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jczuchnowski authored Sep 28, 2022
2 parents 5a711b8 + 92b2ec4 commit dd5e92f
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 18 deletions.
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ addCommandAlias("fmtOnce", "all scalafmtSbt scalafmt test:scalafmt")
addCommandAlias("fmt", "fmtOnce;fmtOnce")
addCommandAlias("check", "all scalafmtSbtCheck scalafmtCheck test:scalafmtCheck")

val zioVersion = "2.0.0"
val zioVersion = "2.0.2"
val zioSchemaVersion = "0.2.0"
val testcontainersVersion = "1.17.3"
val testcontainersScalaVersion = "0.40.10"
Expand Down Expand Up @@ -138,7 +138,7 @@ lazy val jdbc_hikaricp = project
.settings(buildInfoSettings("zio.sql.jdbc-hickaricp"))
.settings(
libraryDependencies ++= Seq(
"com.zaxxer" % "HikariCP" % "5.0.1",
"com.zaxxer" % "HikariCP" % "4.0.3", // 5.x doesn't support Java 1.8
"dev.zio" %% "zio-test" % zioVersion % Test,
"dev.zio" %% "zio-test-sbt" % zioVersion % Test,
"org.testcontainers" % "mysql" % testcontainersVersion % Test,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ class HikariConnectionPool private (hikariDataSource: HikariDataSource) extends

private[sql] val dataSource = hikariDataSource

/**
* Retrieves a JDBC java.sql.Connection as a [[ZIO[Scope, Exception, Connection]]] resource.
* The managed resource will safely acquire and release the connection, and
* may be interrupted or timed out if necessary.
*/
override def connection: ZIO[Scope, Exception, Connection] =
ZIO.acquireRelease(ZIO.attemptBlocking(hikariDataSource.getConnection).refineToOrDie[SQLException])(con =>
ZIO.attemptBlocking(hikariDataSource.evictConnection(con)).orDie
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ object HikariConnectionPoolSpec extends ZIOSpecDefault {
)
} @@ timeout(10.seconds) @@ withLiveClock,
test("connection init SQL should be configurable") {
val initialSql = "SELECT 1 FROM test.test"
val initialSql = "SELECT 1"
(for {
cp <- ZIO.service[HikariConnectionPool]
} yield assertTrue(cp.dataSource.getConnectionInitSql == initialSql))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ object MySqlTestContainer {
ZIO.attemptBlocking {
val c = new MySQLContainer(
mysqlImageVersion = Option(imageName).map(DockerImageName.parse)
).configure { a =>
a.withInitScript("test_schema.sql")
()
}
)
c.start()
c
}
Expand Down
7 changes: 4 additions & 3 deletions jdbc/src/test/scala/zio/sql/JdbcRunnableSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ trait JdbcRunnableSpec extends ZIOSpecDefault with Jdbc {
)
}

val connectionPool: ZLayer[Any, Throwable, ConnectionPool] = poolConfigLayer >>> ConnectionPool.live

private[this] final lazy val jdbcLayer: ZLayer[Any, Any, SqlDriver] =
ZLayer.make[SqlDriver](
poolConfigLayer.orDie,
ConnectionPool.live.orDie,
connectionPool.orDie,
SqlDriver.live
)

Expand All @@ -65,7 +66,7 @@ trait JdbcRunnableSpec extends ZIOSpecDefault with Jdbc {
def both[A, B](fa: => Gen[R, A], fb: => Gen[R, B]): Gen[R, (A, B)] = fa.zip(fb)
}

private[this] def testContainer: ZIO[Scope, Throwable, SingleContainer[_] with JdbcDatabaseContainer] =
val testContainer: ZIO[Scope, Throwable, SingleContainer[_] with JdbcDatabaseContainer] =
ZIO.acquireRelease {
ZIO.attemptBlocking {
val c = getContainer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ object OracleSqlModuleSpec extends OracleRunnableSpec with ShopSchema {
assertZIO(execute(command))(equalTo(2))
},
test("Can insert all supported types") {
val sqlMinDateTime = LocalDateTime.of(-4713, 1, 1, 0, 0)
val sqlMinDateTime = LocalDateTime.of(1, 1, 1, 0, 0)
val sqlMaxDateTime = LocalDateTime.of(9999, 12, 31, 23, 59)

val sqlInstant =
Gen.instant(sqlMinDateTime.toInstant(ZoneOffset.MIN), sqlMaxDateTime.toInstant(ZoneOffset.MAX))

val sqlYear = Gen.int(-4713, 9999).filter(_ != 0).map(Year.of)
val sqlYear = Gen.int(1, 9999).map(Year.of)

val sqlLocalDate = for {
year <- sqlYear
Expand Down Expand Up @@ -216,6 +216,7 @@ object OracleSqlModuleSpec extends OracleRunnableSpec with ShopSchema {
durationCol
).values(row)

// printInsert(insert)
// TODO: ensure we can read values back correctly
// val read =
// select(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ object SqlServerModuleSpec extends SqlServerRunnableSpec with DbSchema {
Gen.option(Gen.int),
sqlLocalDate,
sqlLocalDateTime,
Gen.localTime,
Gen.localTime.map(normLt), // needs to be truncated before saving to the db for predictable outcome
Gen.long,
sqlOffsetDateTime,
sqlOffsetTime,
Expand Down

0 comments on commit dd5e92f

Please sign in to comment.