Squeryl部分更新无法编译

Eug*_*esh 2 squeryl

我不确定squeryl在这里试图告诉我什么:

错误:无法证明org.squeryl.dsl.fsm.Unconditioned =:= org.squeryl.dsl.fsm.Conditioned.

上:

inTransaction {
  update(AppDB.postTable) { p =>
    where(p.id === postId)
    set(p.upVotes := p.upVotes.~ + 1) 
}
Run Code Online (Sandbox Code Playgroud)

错误发生在set子句中

模式:

object AppDB extends Schema {
   val postTable = table[Post]("post")
   val replyTable = table[Reply]("reply")

   val postToReplies = oneToManyRelation(postTable, replyTable)
          .via((p,r) => p.id === r.postId)
    }

    case class Post(body: String, image:Option[String]) extends KeyedEntity[Long] {
      val id: Long = 0
      val posted: Date = new Date()
      var upVotes: Long = 0
      var downVotes: Long = 0
    }

    case class Reply(postId: Long, body: String, image:Option[String]) extends KeyedEntity[Long] {
        val id: Long = 0
        val posted: Date = new Date()
    }
Run Code Online (Sandbox Code Playgroud)

谢谢你的帮助.

jce*_*ern 7

尝试使用()而不是{}围绕你的whereset子句,例如:

inTransaction {
  update(AppDB.postTable) ( p =>
    where(p.id === postId)
    set(p.upVotes := p.upVotes.~ + 1) 
  )
}
Run Code Online (Sandbox Code Playgroud)

我不知道为什么,但我过去曾遇到过问题{}.当我针对您的代码测试更改时,问题似乎得到了解决.