有没有办法在代码中的多行上拆分Slick插值查询?我的查询往往会变得很长。
所以我寻找以下内容:
val query = sql"select * from DOCUMENTS " +
sql"where language = $lang order by publication_date desc"
query.as[ResearchDocument]
但这会导致
type mismatch;
found : scala.slick.jdbc.SQLInterpolationResult[String]
required: String
sql"where language = $lang order by publication_date desc"
^
答案 0 :(得分:6)
好的,看起来像Scala三重引号字符串是要走的路:
val query = sql"""select * from DOCUMENTS
where language = $lang order by publication_date desc"""