4

Linked from this question

I came across Slick's documentation and found it mandates a def * method in the definition of a table to get a mapped projection. So the line looks like this

def * = (name, id.?).<>(User.tupled,User.unapply)

Slick example here

I see the <> method is invoked on a tuple - in this case a Tuple2. The method is defined on the case class ShapedValue in Slick's code. How do I find out the implicit method that is doing the lookup?

Here are my imports:

import scala.concurrent.Await
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration.Duration
import slick.driver.H2Driver.api._
import slick.lifted.ShapedValue
import slick.lifted.ProvenShape
Community
  • 1
  • 1
Som Bhattacharyya
  • 3,972
  • 35
  • 54

1 Answers1

6

So i figured that one out for myself.
The object Shape implements three traits namely ConstColumnShapeImplicits , AbstractTableShapeImplicits and TupleShapeImplicits . These three traits handle the implicit conversions concerning Shapes in Slick . The TupleShapeImplicits houses all implicit conversion methods required to convert a Tuple to a TupleShape.

Now in the line (name, id.?, salary.?).<>(User.tupled,User.unapply) what is happening is that the the method <> has a implicit parameter of Shape The Shape class thus comes in scope for the implicit conversion. And the TupleShapeImplicits comes into scope as well.

Som Bhattacharyya
  • 3,972
  • 35
  • 54