Skip to content

Commit

Permalink
remove default QueryAdapter to make scala3 happy
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-alfers committed Jan 22, 2024
1 parent 5f9ac2b commit ffe608d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
ProblemFilters.exclude[DirectMissingMethodProblem]("akka.persistence.r2dbc.R2dbcSettings.this")
ProblemFilters.exclude[MissingClassProblem]("akka.persistence.r2dbc.internal.Sql$Interpolation$")
ProblemFilters.exclude[DirectMissingMethodProblem]("akka.persistence.r2dbc.internal.Sql.Interpolation")
ProblemFilters.exclude[DirectMissingMethodProblem]("akka.persistence.r2dbc.internal.Sql.Interpolation")
ProblemFilters.exclude[DirectMissingMethodProblem]("akka.persistence.r2dbc.internal.Sql#Interpolation.equals$extension")
ProblemFilters.exclude[DirectMissingMethodProblem]("akka.persistence.r2dbc.internal.Sql#Interpolation.hashCode$extension")
ProblemFilters.exclude[DirectMissingMethodProblem]("akka.persistence.r2dbc.internal.Sql#Interpolation.sql$extension")
ProblemFilters.exclude[DirectMissingMethodProblem]("akka.persistence.r2dbc.internal.Sql#Interpolation.this")
ProblemFilters.exclude[MissingClassProblem]("akka.persistence.r2dbc.internal.h2.H2Utils")
ProblemFilters.exclude[MissingClassProblem]("akka.persistence.r2dbc.internal.h2.H2Utils$")
ProblemFilters.exclude[MissingClassProblem]("akka.persistence.r2dbc.internal.h2.H2Utils$")
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ object Sql {
* to include a literal `?`. Trims whitespace, including line breaks. Standard string interpolation arguments `$` can
* be used.
*/
implicit class Interpolation(val sc: StringContext)(implicit adapter: QueryAdapter = IdentityAdapter) extends AnyRef {
implicit class Interpolation(val sc: StringContext)(implicit adapter: QueryAdapter) extends AnyRef {
def sql(args: Any*): String =
adapter(fillInParameterNumbers(trimLineBreaks(sc.s(args: _*))))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ import io.r2dbc.h2.H2ConnectionFactory
import io.r2dbc.h2.H2ConnectionOption
import io.r2dbc.spi.ConnectionFactory
import java.util.Locale

import scala.concurrent.ExecutionContext

import akka.persistence.r2dbc.internal.codec.IdentityAdapter
import akka.persistence.r2dbc.internal.codec.QueryAdapter

/**
* INTERNAL API
*/
Expand Down Expand Up @@ -116,6 +120,8 @@ private[r2dbc] object H2Dialect extends Dialect {
val durableStateTable = config.getString("state-table")
val durableStateTableWithSchema = schema.map(_ + ".").getOrElse("") + durableStateTable

implicit val queryAdapter: QueryAdapter = IdentityAdapter

val sliceIndexes = if (createSliceIndexes) {
val sliceIndexWithSchema = journalTableWithSchema + "_slice_idx"
val snapshotSliceIndexWithSchema = snapshotTableWithSchema + "_slice_idx"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@

package akka.persistence.r2dbc.internal

import akka.persistence.r2dbc.internal.codec.IdentityAdapter
import akka.persistence.r2dbc.internal.codec.QueryAdapter
import org.scalatest.TestSuite
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec

class SqlSpec extends AnyWordSpec with TestSuite with Matchers {
import Sql.Interpolation

implicit val queryAdapter: QueryAdapter = IdentityAdapter
"SQL string interpolation" should {
"replace ? bind parameters with numbered $ (avoiding escaped ones)" in {
sql"select * from bar where a = ? and qa = 'Question?? Answer!'" shouldBe "select * from bar where a = $1 and qa = 'Question? Answer!'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ package akka.persistence.r2dbc.migration
import scala.concurrent.ExecutionContext
import scala.concurrent.Future
import scala.concurrent.duration.FiniteDuration

import akka.Done
import akka.actor.typed.ActorSystem
import akka.annotation.InternalApi
import akka.dispatch.ExecutionContexts
import akka.persistence.r2dbc.internal.Sql.Interpolation
import akka.persistence.r2dbc.internal.R2dbcExecutor
import akka.persistence.r2dbc.internal.codec.IdentityAdapter
import akka.persistence.r2dbc.internal.codec.QueryAdapter
import io.r2dbc.spi.ConnectionFactory
import org.slf4j.LoggerFactory

Expand All @@ -33,7 +36,7 @@ import org.slf4j.LoggerFactory
logDbCallsExceeding: FiniteDuration,
closeCallsExceeding: Option[FiniteDuration])(implicit ec: ExecutionContext, system: ActorSystem[_]) {
import MigrationToolDao._

implicit val queryAdapter: QueryAdapter = IdentityAdapter
private val r2dbcExecutor =
new R2dbcExecutor(connectionFactory, log, logDbCallsExceeding, closeCallsExceeding)(ec, system)

Expand Down

0 comments on commit ffe608d

Please sign in to comment.