在scala slick 1.0.1中从SomeTable where ...中构造“select(*)> 0”时遇到问题

时间:2013-08-06 13:58:30

标签: scala slick

我正在尝试生成这样的sql语句:

select count(*)>0 from "SomeTable"

使用Scala的光滑1.0.1和postgres。

这是我的代码:

val rows = for(row <- Query(Order)) yield row
println(rows.selectStatement)
val rowCount = (for(l<- Query(rows.length)) yield l).take(0)
println(rowCount.selectStatement)
val e = for(l<-rowCount.take(0)) yield l> 0
println(e.selectStatement)

但它正在生成如下查询:

“行”似乎按预期生成:

select x2."ID", x2."truck_id", x2."pickup", x2."user_uid", x2."user_provider", x2."status" from "Orders" x2`

rowCount肯定是奇怪的。

 select x2.x3 from (select count(1) as x3 from (select x4."ID", x4."truck_id", x4."pickup", x4."user_uid", x4."user_provider", x4."status" from "Orders" x4) x5) x2 where false -->for "rowcount". 

e也是一个不圣洁的野兽。

select x2.x3 > 0 from (select count(1) as x3 from (select x4."ID", x4."truck_id", x4."pickup", x4."user_uid", x4."user_provider", x4."status" from "Orders" x4) x5) x2 where false  ->  huh....weird.

我不太确定,但在我看来,我不太喜欢聚合/分组功能(例如count(*))和Scala slick。有没有人有建议?

0 个答案:

没有答案