Skip to content

Fix slick's proven shape problems #6

Description

@luksow
case class Member(id: UUID, name: String)

object Member {
  
}

class Members(tag: BaseTable.Tag) extends BaseTable[Member](tag, "position") {
  import driver.api._

  def id: Rep[UUID]                             = column[UUID]("id")
  def name: Rep[String]                             = column[String]("name")

  override def * : ProvenShape[Member] =
    (id, name) <> (Member.tupled, Member.unapply)
}

This does not compile for obvious reasons and needs a change to (id, name) <> ((Member.apply _).tupled, Member.unapply).

Even worse, let's consider this:

case class MemberCreateRequest(name: String)

case class Member(id: UUID, name: String)

object Member {
  def apply(request: MemberCreateRequest): Member = Member(UUID.randomUUID(), request.name)
}

class Members(tag: BaseTable.Tag) extends BaseTable[Member](tag, "position") {
  import driver.api._

  def id: Rep[UUID]                             = column[UUID]("id")
  def name: Rep[String]                             = column[String]("name")

  override def * : ProvenShape[Member] =
    (id, name) <> ((Member.apply _).tupled, Member.unapply)
}

It won't compile again due to ambiguous reference.

Can kebs help with that?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions