This is a problem derived from another question. I need to be able to dynamically pass a column to be sorted on in a Slick query which has a left join. The problem in this p
.?
is implemented using <>
which prevents you from later accessing members. So you need to apply the sorting before you do the .?
val data = for {
(computer, company) <- Computer.where(_.name like filter) leftJoin
Company on (_.companyId === _.id)
} yield (computer, company) // <- no .?
val sortedData = orderBy match {
case 2 => data.sortBy(_._1.name) //Works ok, column from a primary table
case 3 => data.sortBy(_._2.name) //Error "Cannot resolve symbol name", because table is optional
}
val optionalJoinData = sortedData.map{
case (computer, company) => (computer, company.?)
} // <- do .? last