Skip to content

Commit

Permalink
Use SetParameter.SetUnit
Browse files Browse the repository at this point in the history
  • Loading branch information
mdedetrich committed Feb 4, 2024
1 parent 912c935 commit b41fad0
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,12 @@ import pekko.stream.javadsl._
import pekko.util.FunctionConverters._
import pekko.util.FutureConverters._
import slick.dbio.DBIO
import slick.jdbc.{ GetResult, SQLActionBuilder, SetParameter, SimpleJdbcAction, TypedParameter }
import slick.jdbc.{ GetResult, SQLActionBuilder, SetParameter, SimpleJdbcAction }

import scala.concurrent.ExecutionContext

object Slick {

private val unitType = new TypedParameter((), SetParameter.SetUnit)

/**
* Java API: creates a Source that performs the specified query against
* the specified Slick database and streams the results through
Expand All @@ -53,7 +51,7 @@ object Slick {
query: String,
mapper: JFunction[SlickRow, T]): Source[T, NotUsed] = {

val streamingAction = SQLActionBuilder(Seq(query), Seq(unitType)).as[T](toSlick(mapper))
val streamingAction = SQLActionBuilder(query, SetParameter.SetUnit).as[T](toSlick(mapper))

ScalaSlick
.source[T](streamingAction)(session)
Expand Down Expand Up @@ -362,7 +360,7 @@ object Slick {
GetResult(pr => mapper(new SlickRow(pr)))

private def toDBIO[T](javaDml: JFunction[T, String]): T => DBIO[Int] = { t =>
SQLActionBuilder(Seq(javaDml.asScala(t)), Seq(unitType)).asUpdate
SQLActionBuilder(javaDml.asScala(t), SetParameter.SetUnit).asUpdate
}

private def toDBIO[T](javaDml: Function2[T, Connection, PreparedStatement]): T => DBIO[Int] = { t =>
Expand Down

0 comments on commit b41fad0

Please sign in to comment.