【问题标题】:scala deprecation warning with playframework and slick带有 playframework 和 slick 的 scala 弃用警告
【发布时间】:2017-07-05 19:05:37
【问题描述】:

大家好,我收到了这个弃用警告

在我的带有 scala 和 slick 的 playframework 应用程序中

[warn] 
\app\dto\processTemplateDTO.scala:95: method columnToOptionColumn in trait API is deprecated: Use an explicit conversion to an Option column with `.?`
[warn]     def processtemplateFK: ForeignKeyQuery[ProcessTemplates, ProcessTemplatesModel] = foreignKey("Process", processtemplate, processTemplates)(_.id, onUpdate = ForeignKeyAction.Restrict, onDelete = ForeignKeyAction.Cascade)

我可以只使用 . 吗?而不是 _.id

非常感谢

【问题讨论】:

  • 可以添加完整的表格代码吗?

标签: scala playframework slick


【解决方案1】:

它的意思是,在编写您的provenShape 实现时,您应该使用以下命令将您的非选项列提升为可选:

case class Coffee(id: Option[Int],name: String)

class Coffees(tag: Tag) extends Table[Coffee]("coffees",tag){
  def id: Rep[Int] = column[Int]("id",O.AutoInc)
  def name: Rep[String] = column[String]("name")
  //see the .? method
  def *: ProvenShape[Coffee] = (id.?,name) <> (Coffee.tupled,Coffey.unapply) 
}

在你的情况下尝试"_.id.?",但不知道为什么你想要一个可以为空的列作为外键。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多