Pergunta

I use slick and playframework 2.1 why "~" is not recognize as operator, why?

object Comments extends IdTable[CommentId, Comment]("COMMENTS") {

def text = column[String]("TEXT")

// you can use your type-safe ID here - it will be mapped to long in database
def authorId = column[UserId]("AUTHOR")

def author = foreignKey("COMMENTS_AUTHOR_FK", authorId, Users)(_.id)

def date = column[DateTime]("DATE")

def base = text ~ authorId ~ date

override def * = id.? ~: base <> (Comment.apply _, Comment.unapply _) //the error happens here.

override def insertOne(elem: Comment)(implicit session: Session): CommentId =
saveBase(base, Comment.unapply _)(elem)

}

the error is:

[error] C:\assigment\slick-advanced\app\models\Comment.scala:30: value ~: is not
a member of scala.slick.lifted.Projection3[String,models.UserId,org.joda.time.DateTime]

why the ~ operator can not apply?

Foi útil?

Solução

The operator it complains about is ~:, not ~. The error is probably just a consequence of the DateTime error. Slick does not support joda time out of the box. This should help: https://github.com/tototoshi/slick-joda-mapper

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top