Slick currently does not support creating nested collections in results
(just like SQL does not). groupBy produces a nested collection. E.g.
(foo:Iterable[_]).groupBy(x=>x) : Iterable[ (_, Iterable[_]) ]
And thus you cannot run such a query with Slick. The problem is that we
currently cannot catch that case statically, but you get the "Cannot
select Path s23 in Ref s9" or "No type for symbol s23 found in Coll..."
in Slick 2.0.
In other cases we can catch this statically, which results in a
"Don't know how to unpack ... to T and pack to G". This means on other
words "We cannot execute a query of this type, because you used illegal
nesting or unsupported data types".
What you can do to fix this is to the operations that produce nested
results locally instead of as a query. In your case that would mean run
the .list before running the .groupBy like this:
val query = (for {
p <- Companies
c <- Computers if
p.id === c.manufacturerId
} yield (
p.id,
p.name,
c.name)).list.groupBy(_._3)
query.map {
case(cusname, pbc) => (cusname, pbc.map(r2 => (r2._1, r2._2, r2._3)))
}
Chris