`def @>[P2,R](c2: Rep[P2])(implicit om: o#arg[JSONType, P2]#to[Boolean, R]) = {
om.column(jsonLib.Contains, n, c2.toNode)
}`
.filter({ case (_, pr) => pr.predicate @> Json.parse(s"""{"userRole":["$userRole"]}""")})
Hi,
I was wondering if something like this is possible using json helpers:
dbConfig.db.run(myTable.filter(_.state.~>("finished") === true).result.headOption)
Where state
is a JSON field on the table having a finished
attribute which is boolean.
However the compiler is complaining:
[error] ... Cannot perform option-mapped operation
[error] with type: (io.circe.Json, Boolean) => R
[error] for base type: (io.circe.Json, io.circe.Json) => Boolean
[error] dbConfig.db.run(myTable.filter(_.state.+>("finished") === true).result.headOption)
[error] ^
[error] ... ambiguous implicit values:
[error] both value BooleanCanBeQueryCondition in object CanBeQueryCondition of type => slick.lifted.CanBeQueryCondition[Boolean]
[error] and value BooleanColumnCanBeQueryCondition in object CanBeQueryCondition of type => slick.lifted.CanBeQueryCondition[slick.lifted.Rep[Boolean]]
[error] match expected type slick.lifted.CanBeQueryCondition[Nothing]
[error] dbConfig.db.run(myTable.filter(_.state.+>("finished") === true).result.headOption)
[error] ^
implicit private val instantColumn: JdbcType[java.time.Instant] = MappedColumnType.base[java.time.Instant, java.sql.Timestamp](
instant => java.sql.Timestamp.from(instant),
column => column.toInstant)
could not find implicit value for parameter tt: slick.ast.TypedType[Option[com.vividsolutions.jts.geom.Geometry]]
. I have defined my postgres profile as given at https://github.com/tminglei/slick-pg. Am I missing something here?
com.vividsolutions.jts.geom.Geometry
with String
, the error goes away.
I have used codegen with slick pg. The generated code throws
could not find implicit value for parameter tt: slick.ast.TypedType[Option[com.vividsolutions.jts.geom.Geometry]]
. I have defined my postgres profile as given at https://github.com/tminglei/slick-pg. Am I missing something here?
Any suggestion on that?
select last_name,
first_name,
(select string_agg(medical_specialty.name, '; ') from medical_specialty join doctor_medical_specialty dms on medical_specialty.id = dms.medical_specialty where dms.doctor = doctor.id) as specialties,
(select string_agg(medical_subspecialty.name, '; ') from medical_subspecialty join doctor_medical_subspecialty dms on medical_subspecialty.id = dms.medical_subspecialty where dms.doctor = doctor.id) as subspecialties,
cell_number,
email_address,
rating,
(select string_agg(hospital.name, '; ') from hospital join doctor_hospital dh on hospital.id = dh.hospital where dh.doctor = doctor.id) as hospitals,
(select string_agg(o.name, '; ') from doctoroffice o where o.doctor = doctor.id) as offices
from doctor
Doctors
.map { doc =>
val specialties =
ManageDoctorsDbActions.specialtiesQuery.filter(_._1 === doc.lookup).map(t => stringAgg(t._2.name, "; "))
(doc, specialties)
}
Doctors
.map { doc =>
val specialties =
stringAgg(ManageDoctorsDbActions.specialtiesQuery.filter(_._1 === doc.lookup).map(t => t._2.name), "; ")
(doc, specialties)
}
import FunctionSymbolExtensionMethods._
val StringAgg = new Library.SqlAggregateFunction("string_agg")
def stringAgg(q: Query[Rep[String], _, Seq], delimiter: String)
(implicit tm: TypedType[Option[String]]): Rep[Option[String]] =
StringAgg.column[Option[String]](q.toNode, LiteralNode(delimiter))
...
Doctors
.map { doc =>
val specialties =
stringAgg(ManageDoctorsDbActions.specialtiesQuery.filter(_._1 === doc.lookup).map(_._2.name), ", ")
(doc, specialties)
}