1

Well I have some problems regarding class names actually, here goes my problem

I have a case class like this,

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)
}

And Projection class for 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
}

And unfortunately, case class name == object

object Foo {
.
.
.
}

This is an old code and the case class and the object has been used in many places so I can't change the name of the case class or the object, and since they have the same name I have having problems creating a projection class, I am getting errors in this line:

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

And when I change the case class name and use it in the projection class it works properly, I have am having this problem because case class and object have the same name. Is there any solution to this problem, can it be solved without changing the case class/object name ??

mane
  • 1,149
  • 16
  • 41
  • You could try to add the full path to the class if both are imported in the same file: `(package.path.to.Foo.tupled, package.path.to.Foo.unapply)` – Ende Neu Aug 06 '14 at 11:02
  • Even if I put in the full path it would be the same, because the object and case class have the same name, and object is taking precedence over case class. And the thing is both case class and object and the projection class are in the same file, can't change the location of case class and object. – mane Aug 06 '14 at 11:04
  • Ah sorry, I thought they were defined in different files and so that they had different package names, my bad. One other thing you could probably try is to change the object name in the import like [this question shows](http://stackoverflow.com/questions/2871822/how-do-i-exclude-rename-some-classes-from-import-in-scala), this should be enough to avoid confilcts. – Ende Neu Aug 06 '14 at 11:05
  • Yes, I did what you suggested but unfortunately again, the object takes precedence over the case class. – mane Aug 06 '14 at 11:13

1 Answers1

5

You can try like this

(Foo.apply _).tupled
Uraniium
  • 109
  • 6