scala - Is it possible to define dynamic projections in Slick? -
i have query joining many tables. i'd able parametrize fields should retrieved (sometimes complex sql postgis functions). let's initial query built this:
def buildquery() = { c <- coffees if c.price > 9.0 s <- c.supplier } yield (c.name, s.name)
now want 1 of yielded values dependent on parameter, example become:
val param = true def buildquery() = { c <- coffees if c.price > 9.0 s <- c.supplier } yield (c.name, if (param) s.name else null)
such code won't work, slick internals throw nullpointerexception. there reasonable way dynamically build yield part based on input parameters?
as far know use slick's "case dsl": https://github.com/slick/slick/blob/master/src/main/scala/scala/slick/lifted/case.scala
Comments
Post a Comment