diff --git a/jdbc/src/main/scala/zio/sql/SqlDriverLiveModule.scala b/jdbc/src/main/scala/zio/sql/SqlDriverLiveModule.scala index 4d363a583..690d479c7 100644 --- a/jdbc/src/main/scala/zio/sql/SqlDriverLiveModule.scala +++ b/jdbc/src/main/scala/zio/sql/SqlDriverLiveModule.scala @@ -45,7 +45,7 @@ trait SqlDriverLiveModule { self: Jdbc => ZIO.attemptBlocking { val statement = conn.createStatement() delete.map(delete_ => statement.addBatch(renderDelete(delete_))) - statement.executeBatch().foldLeft(0) { case (acc, el) => acc + el } + statement.executeBatch().sum }.refineToOrDie[Exception] def update(update: Update[_]): IO[Exception, Int] = @@ -65,7 +65,7 @@ trait SqlDriverLiveModule { self: Jdbc => ZIO.attemptBlocking { val statement = conn.createStatement() update.map(update_ => statement.addBatch(renderUpdate(update_))) - statement.executeBatch().foldLeft(0) { case (acc, el) => acc + el } + statement.executeBatch().sum }.refineToOrDie[Exception] def read[A](read: Read[A]): Stream[Exception, A] = diff --git a/postgres/src/test/scala/zio/sql/postgresql/TransactionSpec.scala b/postgres/src/test/scala/zio/sql/postgresql/TransactionSpec.scala index 1956fc1df..ffdadc64b 100644 --- a/postgres/src/test/scala/zio/sql/postgresql/TransactionSpec.scala +++ b/postgres/src/test/scala/zio/sql/postgresql/TransactionSpec.scala @@ -83,7 +83,6 @@ object TransactionSpec extends PostgresRunnableSpec with DbSchema { test("Transaction failed and no row was inserted updated or deleted") { val deleteQuery = deleteFrom(customers).where(verified === false) val id1 = UUID.randomUUID() - // val id2 = UUID.randomUUID() val c1 = Customer( id1, @@ -110,11 +109,10 @@ object TransactionSpec extends PostgresRunnableSpec with DbSchema { val batchResult = for { deleted <- deleteQuery.run - // inserted <- insertStmt.run _ <- ZIO.fail(insertStmt.run).exit updated <- updateStmt.run - } yield deleted + updated // + inserted + } yield deleted + updated val result = (for { tx <- transact(batchResult)