scala - Reusing queries with MappedProjection in slick
问题描述
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?
解决方案
推荐阅读
- python - 如何将 gmail 笔记导入 python?
- javascript - 创建 CSS 和 JavaScript 文件
- html - 基于 Salesforce 中 IF 条件的电子邮件模板中的粗体文本
- jmeter - 测量仪 | API 500 内部服务器错误 | 后端服务器:Azure Appservice
- arrays - 用于交叉检查的 Excel 数组功能
- r - R:根据单元格位置对矩阵列表中的单元格进行排名
- python - 在 Python 中替换占位符时出错
- python - 从 cygwin 安装 uWSGI 但无法从已安装的包中找到
- javascript - 用户输入添加有问题
- python - 如何从抓取 Python 中填充空记录?