带有 playframework 和 slick 的 scala 弃用警告

scala deprecation warning with playframework and slick

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

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

[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

非常感谢

它的意思是,在编写 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.?" 但不确定为什么你想要一个可为空的列作为外键。