I have the following code below, attempting to set up a relatively straightforward table mapping with companion class.
case class Client(
id: Integer,
givenName: String,
familyName: String,
birthDate: Option[Date],
nationality: Option[String]
)
class ClientsTable(tag: Tag) extends Table[Client](tag, "Client") {
def id = column[Int]("ID", O.PrimaryKey, O.AutoInc)
def givenName = column[String]("GIVEN_NAME", O.NotNull)
def familyName = column[String]("FAMILY_NAME", O.NotNull)
def birthDate = column[Date]("BIRTH_DATE", O.Nullable)
def nationality = column[String]("NATIONALITY", O.Nullable)
def * = (id, givenName, familyName, birthDate.?, nationality.?) <> ((Client.apply _).tupled, Client.unapply)
}
The error I'm seeing is on the <>
operator.
No matching Shape found. Slick does not know how to map the given types.
Possible causes: T in Table[T] does not match your * projection. Or you use an unsupported type in a Query (e.g. scala List).
Required level: scala.slick.lifted.FlatShapeLevel Source type: (scala.slick.lifted.Column[Int], scala.slick.lifted.Column[String], scala.slick.lifted.Column[String], scala.slick.lifted.Column[Option[java.sql.Date]], scala.slick.lifted.Column[Option[String]]) Unpacked type: (Integer, String, String, Option[java.sql.Date], Option[String]) Packed type: Any
Now, there's a popular answer that describes aspects of slick projections in detail that I've read backwards and forwards, and still I'm missing something here.
I get that this projection function is attempting to create a default projection of the table for easy later query with the DSL. And I get that what I'm trying to do here is transform a series of tuples (what really comes back from a database) into a series of Client
objects. I don't fully understand the magic of what's happening as of <>
and everything after it, and so I'm a bit stuck on how to resolve this error.