Hey,
When reading a composite with the string {[ with Plain SQL Query getting a
java.lang.IllegalArgumentException: WRONG token type: Marker()
at com.github.tminglei.slickpg.utils.PgTokenHelper$.getChildren(PgTokenHelper.scala:100)
at com.github.tminglei.slickpg.PgCompositeSupportUtils$CompositeConverter.fromToken(PgCompositeSupport.scala:133)
at com.github.tminglei.slickpg.PgCompositeSupportUtils.$anonfun$mkCompositeFromString$1(PgCompositeSupport.scala:60)
Reproduce with
package slickpg.composite
import com.github.tminglei.slickpg.composite.Struct
import com.github.tminglei.slickpg.{ExPostgresProfile, PgCompositeSupport}
import com.typesafe.config.{Config, ConfigFactory}
import slick.basic.DatabaseConfig
import slick.jdbc.PostgresProfile.api._
import slick.jdbc.{GetResult, PostgresProfile, SetParameter}
import scala.concurrent.Await
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration.DurationInt
object Reproduce extends App {
private trait PostgreSQLProfile extends ExPostgresProfile with PgCompositeSupport {
object MyAPI extends ExtPostgresAPI
override val api: MyAPI.type = MyAPI
}
private object PostgreSQLProfile extends PostgreSQLProfile
import PostgreSQLProfile._
private case class Foo(a: Boolean, b: String) extends Struct
private object Foo {
private val sqlTypeName = "foo"
implicit val typeMapper: PostgreSQLProfile.GenericJdbcType[Foo] =
createCompositeJdbcType[Foo](sqlTypeName)
implicit val setParameter: SetParameter[Foo] =
createCompositeSetParameter[Foo](sqlTypeName)
implicit val getResult: GetResult[Option[Foo]] =
GetResult(r => nextComposite[Foo](r))
}
private val foo = Foo(a = true, b = "{[")
private val config: Config = ConfigFactory.load()
private val dbConfig: DatabaseConfig[PostgresProfile] = DatabaseConfig.forConfig("slick.dbs.default", config)
private val db = dbConfig.db
private val eventual = for {
_ <- db.run(sqlu"create type foo as (a boolean, b text)")
_ <- db.run(sqlu"create table bar (err foo)")
_ <- db.run(sqlu"insert into bar (err) values ($foo)")
_ <- db.run(sql"select err from bar".as[Option[Foo]]) // throws
} yield ()
Await.result(eventual, 10.seconds)
}
Using
- Slick 3.6.1
- slick-pg 0.23.1
- Scala 2.13.16
- Postgres 17
P.S.: Thanks for slick-pg!!!
Hey,
When reading a composite with the string
{[with Plain SQL Query getting aReproduce with
Using
P.S.: Thanks for slick-pg!!!