2

How does one reuse complex queries with mapping to custom rows for query composition in slick?

Given some complex query with mapping.

case class ComplexQueryResult( someValue: SomeValue / * other values */)
val aComplexQuery =
  // many joins resulting in a complex query with a map
  // to convert the result into something more readable
  .map {
    case (/* complex touple */) =>
      ComplexQueryResult( /* value assignment */) <> ((ComplexQueryResult.apply _).tupled, ComplexQueryResult.unapply)
  }

The type of this query will be Query[MappedProjection[ComplexQueryResults, /* other query information */]

What I would like to do is reuse this query in another join, so that I can do:

val composedQuery =
  aComplexQuery
    .join(someOtherQuery)
    .on { case(complexQueryResult, /* result of someOtherQuery */) =>
      // << here lies the source of my confusion
    }

Unfortunately there seems to be no way to access the elements of a mapped projection to perform another join. How do I join such queries?

Lukasz
  • 2,257
  • 3
  • 26
  • 44

0 Answers0