0

我有一个包含几列的表,其中两个是: 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]

有谁知道我做错了什么?

4

1 回答 1

0

不确定这是否是同一件事,但请参阅这个巧妙的问题。上游已经修复了,但是1.0.0版本还是有问题。

于 2013-04-23T06:51:52.093 回答