I am in the process of migrating from Slick to Slick 2, and in Slick 2 you are meant to use the tupled
method when projecting onto a case class (as shown here http://slick.typesafe.com/doc/2.0.0-RC1/migration.html)
The problem is when the case class has a companion object, i.e. if you have something like this
case class Person(firstName:String,lastName:String) {
}
Along with a companion object
object Person {
def something = "rawr"
}
In the same scope, the tupled
method no longer works, because its trying to run tupled
on the object
, instead of the case class
.
Is there a way to retrieve the case class
of Person
rather than the object
, so you can call tupled
properly?
This is very similar to what Alexey Romanov said, but in order to avoid lifting
apply
whenever you needtupled
, we just add it to our companion objects.Now you can call
Person.tupled
just like you would have if it didn't have a companion object.You can also write
to avoid repeating the types.
To build on some of the other comments you could do the following as well since tuple is calling the generated default apply method for the case class.
One workaround is define a companion object as follows:
See. https://groups.google.com/d/msg/scala-user/jyWBMz5Qslw/Bryv4ftzRLgJ