Slick 3.0.0升级 - 使用通用列类型的默认投影

时间:2015-06-02 11:56:27

标签: scala upgrade slick

我在Slick 2.1.0中使用了通用列的表定义,但无法在3.0.0中使用它,下面是表结构的详细信息。

abstract class SomeTable[V](tag: Tag, schemaName: String, tableName: String)
extends Table[(String, Int, Date, Timestamp, V)](tag, Some(schemaName), tableName) {

  def entityKey = column[String]("ENTITY_KEY")

  def someId = column[Int]("SOME_ID")

  def someDate = column[Date]("SOME_DATE")

  def someTime = column[Timestamp]("SOME_TIME")

  def someValue: Rep[V]

  def * = (entityKey, someId, someDate, someTime, someValue)
}

错误详情 -

[error]  found   : (slick.lifted.Rep[String], slick.lifted.Rep[Int],    slick.lifted.Rep[java.sql.Date], slick.lifted.Rep[java.sql.Timestamp], slick.lifted.Rep[V])

[error]  required: slick.lifted.ProvenShape[(String, Int, java.sql.Date, java.sql.Timestamp, V)]

我认为错误的原因是“someValue”,它是泛型类型,无法解析为ProvenShape。

请告诉我任何解决此错误的建议。感谢。

1 个答案:

答案 0 :(得分:1)

我遇到了同样的问题,并且能够通过更改为:

来编译代码
abstract class SomeTable[V](tag: Tag, schemaName: String, tableName: String)
extends Table[(String, Int, Date, Timestamp, V)](tag, Some(schemaName), tableName) {

  def entityKey = column[String]("ENTITY_KEY")

  def someId = column[Int]("SOME_ID")

  def someDate = column[Date]("SOME_DATE")

  def someTime = column[Timestamp]("SOME_TIME")

  def someValue: Rep[V]

  def *: ProvenShape[(String, Int, Date, Timestamp, V)] = proveShapeOf(entityKey, someId, someDate, someTime, someValue)
}