実際、クラス名に関していくつか問題があります。ここに問題があります
私はこのようなケースクラスを持っています、
case class Foo(
val compositeKey: String, // clientId-now-requestId
val requestPath: String,
val requestStatus: String) {
def this() = this("", "", "")
def someData = this.compositeKey.split("-")(0)
def someData2 = this.compositeKey.split("-")(2)
}
そしてSlickのプロジェクションクラス、
class Foos(tag: Tag) extends Table[Foo](tag, "Foo") {
def compositeKey: Column[String] = column[String]("composite_key", O.PrimaryKey)
def requestPath: Column[String] = column[String]("request_path")
def requestStatus: Column[String] = column[String]("request_status")
def * : ProvenShape[ClientApiLog] = (compositeKey, requestPath, requestStatus) <> (Foo.tupled, Foo.unapply) //Error is thrown in this line
}
残念ながら、ケース クラス名 == オブジェクト
object Foo {
.
.
.
}
これは古いコードであり、ケース クラスとオブジェクトは多くの場所で使用されているため、ケース クラスまたはオブジェクトの名前を変更することはできません。それらは同じ名前であるため、プロジェクション クラスの作成に問題があります。次の行でエラーが発生します。
def * : ProvenShape[Foo] = (compositeKey, requestPath, requestStatus) <> (Foo.tupled, Foo.unapply)
- Implicit conversions found: (compositeKey, requestPath, requestStatus) => anyToToShapedValue((compositeKey, requestPath,
requestStatus))
- value tupled is not a member of object models.Foo
- implements scala.slick.lifted.AbstractTable.$times
そして、ケースクラス名を変更してそれをプロジェクションクラスで使用すると、正しく動作しますが、ケースクラスとオブジェクトが同じ名前であるため、この問題が発生しています。この問題の解決策はありますか? ケース クラス/オブジェクト名を変更せずに解決できますか??