【发布时间】:2024-04-28 08:30:02
【问题描述】:
我使用的是 scala 版本 2.12.6 和 slick 版本 3.2.3
我想用
连接来自 postgres 数据库的多个表- 描述和产品之间的1:1关系
- 1:0/1 关系 在产品和价格之间和
- 价格和货币之间的 1:n 关系
想要的输出:
(描述、产品、价格、Seq[Option[currencies])
到目前为止我所拥有的:
val query = (for {
(((description, product), price), currencies) <- ((descriptions.filter(_.language === lang.locale.toLanguageTag()) join products on (_.productId === _.id)) joinLeft prices on (_._2.id === _.priceId)) joinLeft currencies on (_._2.map(_.id) === _.priceId)
} yield (description, product, price, currencies))
但是这段代码导致
(描述、产品、价格、[选项[货币])
有重复的行
【问题讨论】: