问题
Is there any way to split a Slick interpolated query over multiple lines in your code? My queries tend to get rather long.
So I look for something like the following:
val query = sql"select * from DOCUMENTS " +
sql"where language = $lang order by publication_date desc"
query.as[ResearchDocument]
But this results in
type mismatch;
found : scala.slick.jdbc.SQLInterpolationResult[String]
required: String
sql"where language = $lang order by publication_date desc"
^
回答1:
Ok, seems like the Scala triple quote string is the way to go:
val query = sql"""select * from DOCUMENTS
where language = $lang order by publication_date desc"""
来源:https://stackoverflow.com/questions/22091206/how-can-i-split-out-a-slick-interpolated-query-over-multiple-lines