I defined a custom type Status and can use it fine for insert and update, but not on filter. What am I missing?
I'm on Scala 2.10.3 and Slick 2.0.2.
The compiler says:
Error typechecking MappedTo expansion: class Status is abstract; cannot be instantiated
Error typechecking MappedTo expansion: class type required but Test.Foo.Two.type found
object Test {
import scala.slick.driver.MySQLDriver.simple._
object Foo {
sealed abstract class Status(val value: String) extends MappedTo[String]
object One extends Status("one")
object Two extends Status("two")
implicit val statusColumnType =
MappedColumnType.base[Status, String](_.value, _ match {
case One.value ⇒ One
case Two.value ⇒ Two
})
}
case class Foo(id: Long, status: Foo.Status)
class FooT(tag: Tag) extends Table[Foo](tag, "Foo") {
import Foo._
def id = column[Long]("id")
def status = column[Status]("status")
def * = (id, status) <> ((Foo.apply _).tupled, Foo.unapply)
}
implicit val mockSession: scala.slick.jdbc.JdbcBackend.SessionDef = ???
val tq = TableQuery[FooT]
tq.map(_.status).update(Foo.Two) //compiles fine
tq.filter(_.status === Foo.Two) //doesn't compile
}
Thank you!