【问题标题】:The "~:" is what meaning in slick and why the DateTime did not recognize“〜:”是光滑的含义以及为什么DateTime无法识别
【发布时间】:2013-12-27 05:36:26
【问题描述】:

我使用 slick 和 playframework 2.1 为什么“~”不能被识别为操作符,为什么?

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)

}

错误是:

[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]

为什么~操作符不能应用?

【问题讨论】:

  • 您的slick 版本是什么?看来~:appears1.0.0

标签: scala playframework-2.1 slick


【解决方案1】:

它抱怨的运营商是~:,而不是~。该错误可能只是 DateTime 错误的结果。 Slick 不支持开箱即用的 joda time。这应该会有所帮助:https://github.com/tototoshi/slick-joda-mapper

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-25
    • 2016-10-12
    • 2017-07-13
    • 2021-04-27
    • 2020-01-27
    相关资源
    最近更新 更多