在光滑中使用groupBy时出现奇怪的异常

时间:2013-04-22 10:43:05

标签: scala slick

我有一个包含几列的表,其中两列是:vendingMachineId(重复),每个列都有一个时间戳。

我想获取每个vendingMachineId的最新时间戳,所以我这样做了:

def getLastReading(assetIds: List[Int])(implicit db: Session): Map[Int, String] = {
    val vmrps = (((for {
      vmrp <- VendingMachineReadingProducts if (vmrp.vendingMachineId inSet assetIds)
    } yield (vmrp.vendingMachineId, vmrp.timestamp)).sortBy(_._2.desc)).groupBy(x => (x._1, x._2))).map {
      case (all, q) => all._1 -> all._2
    }.list

    vmrps map {
      case (assetId, timestamp) => {
        assetId -> (new SimpleDateFormat(DateTimeUtils.defaultDateTimeFormat)).format(timestamp)
      }
    } toMap
  }

问题是我收到一个奇怪的例外:

scala.slick.SlickException: Unexpected node Ref @20339870 -- SQL prefix: select 
    at scala.slick.driver.BasicStatementBuilderComponent$QueryBuilder.toComprehension(BasicStatementBuilderComponent.scala:75) ~[slick_2.10-1.0.0.jar:1.0.0]
    at scala.slick.driver.BasicStatementBuilderComponent$QueryBuilder.expr(BasicStatementBuilderComponent.scala:285) ~[slick_2.10-1.0.0.jar:1.0.0]
    at scala.slick.driver.PostgresDriver$QueryBuilder.expr(PostgresDriver.scala:55) ~[slick_2.10-1.0.0.jar:1.0.0]
    at scala.slick.driver.BasicStatementBuilderComponent$QueryBuilder.buildSelectPart(BasicStatementBuilderComponent.scala:155) ~[slick_2.10-1.0.0.jar:1.0.0]

有谁知道我做错了什么?

1 个答案:

答案 0 :(得分:0)

不确定这是否相同,但请参阅this光滑的问题。它已在上游修复,但1.0.0版仍然存在问题。