Skip to content

Imported custom TypeMapper doesn't work in Scala 2.13.14 #22

Open
@lihaoyi

Description

@lihaoyi

Example code below. Problem goes away with Scala 3.4.2

lihaoyi scalasql-test$ cat ./project/build.properties

sbt.version=1.9.9
lihaoyi scalasql-test$ cat ./build.sbt

val scalasqlTest = (project in file("."))
  .settings(
    scalaVersion := "2.13.14",
    libraryDependencies ++= Seq(
      "com.lihaoyi" %% "scalasql" % "0.1.4",
    )
  )
lihaoyi scalasql-test$ cat ./src/main/scala/test.scala

import scalasql.{Expr, Sc, Table}
import java.sql.{JDBCType, PreparedStatement, ResultSet}
import scalasql.core.{Queryable, SqlStr, TypeMapper}
import java.util.Date

object UtilDate {

  implicit val UtilDateMapper: TypeMapper[Date] = new UtilDateType
  class UtilDateType extends TypeMapper[Date] {
    def jdbcType = JDBCType.TIMESTAMP
    def get(r: ResultSet, idx: Int) = new Date(r.getDate(idx).getTime)
    def put(r: PreparedStatement, idx: Int, v: Date) =
      r.setDate(idx, new java.sql.Date(v.getTime))
  }
}
import UtilDate._

case class TimeInterval[F[_]](
    beginTime: F[Date],
)
object TimeInterval extends Table[TimeInterval]

object Main extends App {
  println("hallo")
}
lihaoyi scalasql-test$ sbt compile

[info] welcome to sbt 1.9.9 (Homebrew Java 22.0.1)
[info] loading project definition from /Users/lihaoyi/Downloads/scalasql-test/project
[info] loading settings for project scalasqlTest from build.sbt ...
[info] set current project to scalasqlTest (in build file:/Users/lihaoyi/Downloads/scalasql-test/)
[info] Executing in batch mode. For better performance use sbt's shell
[info] compiling 1 Scala source to /Users/lihaoyi/Downloads/scalasql-test/target/scala-2.13/classes ...
[error] /Users/lihaoyi/Downloads/scalasql-test/src/main/scala/test.scala:21:29: could not find implicit value for parameter e: scalasql.Queryable.Row[scalasql.core.Expr[java.util.Date],java.util.Date]
[error] object TimeInterval extends Table[TimeInterval]
[error]                             ^
[error] one error found
[error] (Compile / compileIncremental) Compilation failed
[error] Total time: 1 s, completed 11 Aug 2024, 9:36:21 am

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions