Skip to content

Instantly share code, notes, and snippets.

@Pyppe
Created March 26, 2014 15:16
Show Gist options
  • Save Pyppe/9785721 to your computer and use it in GitHub Desktop.
Save Pyppe/9785721 to your computer and use it in GitHub Desktop.
Slick 2.0.1: How to map from Set[String] to Option[String]
implicit val SetOfStrings = MappedColumnType.base[Set[String], Option[String]] (
values => values match {
case values if values.nonEmpty => Some(values.toSeq.sorted.mkString("\n"))
case _ => None
},
str => str.map(_.split('\n').toSet).getOrElse(Set.empty)
)
// could not find implicit value for evidence parameter of type SchemaBase.this.driver.BaseColumnType[Option[String]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment