How to write/use a anorm Extractor like rowToStringSequence Column[Seq[String]]

295 views Asked by At

i wrote this row converter.

implicit def rowToStringSequence: Column[Seq[String]] = Column.nonNull { (value, meta) =>
    val MetaDataItem(qualified, nullable, clazz) = meta
    value match {
      case data: Seq[String] => Right(data)
      case _ => Left(TypeDoesNotMatch(
        "Cannot convert " + value + ":" + value.asInstanceOf[AnyRef].getClass +
        " to String Array for column " + qualified))
    }
  }

Unfortunately, I do not know how to use it within a case class. For instance:

case class profile ( eyeColor: Seq[String] )

The profile companion object:

object Profile{
  val profile= {
      get[Seq[String]]("eyeColor") map {
        case
        eyeColor => Profile(eyeColor)
      }
   }
}

The compilation error message is: could not find implicit value for parameter extractor: anorm.Column[Seq[String]]

I need a hint.

Thank you!!

1

There are 1 answers

0
cchantep On

anorm.Column is made to convert JDBC data to desired Scala type. So first question is which kind of JDBC you want to convert as Seq[String] (not being by itself a JDBC type).