I have a Slick query with two left joins (which end up as a Rep[Option[...]]
) and column maps. I need to filter (using like
) on the results. A row has to be included in the results if any of three columns match the like
criteria, so I can't pre-filter the tables - I have to filter the resulting join, Rep[Option]
s and all.
I can't figure how to filter the Rep[Option[String]]
columns. The below code does not compile due to "cannot resolve symbol ||" - if compiles perfectly when I remove the Rep[Option]
columns.
val joinedTable = Sites.map(s=>(s.id, s.gisId))
.joinLeft(SiteText.filter(_.lang==="jp").map(l=>(l.name, l.siteId))).on{ case(s,t)=>s._1===t._2 }
.joinLeft(SiteText.filter(_.lang==="en").map(l=>(l.name, l.siteId))).on{ case(st,t)=>st._1._1===t._2 }
val searchedTable = joinedTable.filter { row =>
List(
searchStr.map( t => row._1._1._2 like t ),
searchStr.map( t => row._1._2.map(_._1 like t) ),
searchStr.map( t => row._2.map(_._1 like t) )
).collect({case Some(criteria) => criteria}).reduceLeftOption(_ || _).getOrElse(true: Rep[Boolean])
}