Search code examples
scalaslick

How to return compound types in Slick's Case-If-Then-Else


I just start dipping my toe into Slick.

In the coffee-supplier example, I try "Case If Then Else" like this:

val q = coffees.withFilter(_.price > 9.0).flatMap({ c =>
  suppliers.withFilter(_.id == c.supID).map({ s =>
    val t = c.name > s.name
    Case If t Then { (c.name, s.name) } Else { (s.name, c.name) }
  })
})

The compiler emits an error:

could not find implicit value for evidence parameter of type scala.slick.ast.TypedType[(scala.slick.lifted.Column[String], scala.slick.lifted.Column[String])]
        Case If t Then { (c.name, s.name) } Else { (s.name, c.name) }
                         ^

Much the same error apears for other compound types like List as well. I guess I'm on my own to define an implicit for the type in question but I'm not sure where to start.


Solution

  • Currently not support, I created a ticket: https://github.com/slick/slick/issues/866

    Workaround: Write individual If Then constructs for each scalar value