What package to import to include || symbol?

19 views
Skip to first unread message

Sanjarbek Amatov

unread,
Sep 29, 2016, 11:44:16 a.m.2016-09-29
to Slick / ScalaQuery
val q4 = coffees.filter { coffee =>
  List(
      criteriaColombian.map(coffee.name === _),
      criteriaEspresso.map(coffee.name === _),
      criteriaRoast.map(coffee.name === _) // not a condition as `criteriaRoast` evaluates to `None`
  ).collect({case Some(criteria)  => criteria}).reduceLeftOption(_ || _).getOrElse(true: Rep[Boolean])
}

This is a code from slick official documenation, but in my case || symbol not found. What package I need to import?

Sanjarbek Amatov

unread,
Sep 29, 2016, 10:10:57 p.m.2016-09-29
to Slick / ScalaQuery
Solved. In my case one of column field (patient.lastname) was Option type.
val ordersFilterByIdQuery = filterId.map { stringValue =>
try {
val intValue = stringValue.toInt
orders.filter(_.id === intValue)
} catch {
case _ => orders
}
}.getOrElse(orders)
val patientsFilterBySurnameQuery = patients.filter { patient =>
List(
filterPatientSurname.map(stringValue => patient.surname.toLowerCase like s"%${stringValue.toLowerCase}%"),
filterPatientSurname.map(stringValue => patient.firstname.toLowerCase like s"%${stringValue.toLowerCase}%"),
filterPatientSurname.map(stringValue => patient.lastname.map(lastnameColumn=> lastnameColumn.toLowerCase like s"%${stringValue.toLowerCase}%").getOrElse(false))

).collect({ case Some(criteria) => criteria }).reduceLeftOption(_ || _).getOrElse(true: Rep[Boolean])
}

val query = for {
os <- ordersFilterByIdQuery
p <- patientsFilterBySurnameQuery if os.patientId === p.id
d <- doctors if os.doctorId === d.id
orgs <- organizations if os.organizationId === orgs.id
} yield (os, p, d, orgs)
db.run(query.result)

четверг, 29 сентября 2016 г., 21:44:16 UTC+6 пользователь Sanjarbek Amatov написал:
Reply all
Reply to author
Forward
0 new messages