Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
lihaoyi opened this issue Aug 11, 2024 · 0 comments
Open

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

lihaoyi opened this issue Aug 11, 2024 · 0 comments

Comments

@lihaoyi
Copy link
Member

lihaoyi commented Aug 11, 2024

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant