如何通过映射到自定义行来重用复杂的查询,以实现光滑的查询组合?
给出一些带有映射的复杂查询。
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)
}
此查询的类型为Query[MappedProjection[ComplexQueryResults, /* other query information */]
我想做的是在另一个联接中重用此查询,以便我可以这样做:
val composedQuery =
aComplexQuery
.join(someOtherQuery)
.on { case(complexQueryResult, /* result of someOtherQuery */) =>
// << here lies the source of my confusion
}
不幸的是,似乎没有办法访问映射投影的元素来执行另一个连接。如何加入此类查询?