如何在 Slick 的 Case

编程入门 行业动态 更新时间:2024-10-23 15:28:49
本文介绍了如何在 Slick 的 Case-If-Then-Else 中返回复合类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我刚刚开始将脚趾浸入 Slick 中.

I just start dipping my toe into Slick.

在咖啡供应商示例中,我尝试Case If Then Else",如下所示:

In the coffee-supplier example, I try "Case If Then Else" like this:

val q = coffees.withFilter(_.price > 9.0).flatMap({ c => suppliers.withFilter(_.id == c.supID).map({ s => val t = c.name > s.name Case If t Then { (c.name, s.name) } Else { (s.name, c.name) } }) })

编译器发出错误:

could not find implicit value for evidence parameter of type scala.slick.ast.TypedType[(scala.slick.lifted.Column[String], scala.slick.lifted.Column[String])] Case If t Then { (c.name, s.name) } Else { (s.name, c.name) } ^

对于其他复合类型(如 List),也会出现很多相同的错误.我想我需要自己为所讨论的类型定义一个隐式,但我不确定从哪里开始.

Much the same error apears for other compound types like List as well. I guess I'm on my own to define an implicit for the type in question but I'm not sure where to start.

推荐答案

目前不支持,我创建了一个票:github/slick/slick/issues/866

Currently not support, I created a ticket: github/slick/slick/issues/866

解决方法:为每个标量值编写单独的 If Then 构造

Workaround: Write individual If Then constructs for each scalar value

更多推荐

如何在 Slick 的 Case

本文发布于:2023-10-24 17:01:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1524503.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何在   Slick   Case

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!