Question

I'm not sure what squeryl is trying to tell me here:

Error: Cannot prove that org.squeryl.dsl.fsm.Unconditioned =:= org.squeryl.dsl.fsm.Conditioned.

On:

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

The error is on the set clause

schema:

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()
    }

Thanks for any help.

Was it helpful?

Solution

Try using () instead of {} around your where and set clauses, like:

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

I am not sure why, but I have had issues with {} in the past. When I tested the change against your code, the problem seemed to get resolved.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top