kaboom kaboom - 2 months ago 96
Scala Question

Value sql is not a member of StringContext

Why, having the following code Scala returns

value sql is not a member of StringContext
?

I'm using Slick with Play Framework.

val db = Database.forConfig("db")
val query = sql"""select ID from TEACHER""".as[String]
val people = db.withSession{ implicit session =>
Ok(query.list)

Answer

You can use the import import driver.api._ from the library com.typesafe.play:play-slick_2.11:2.0.0. This should work:

import driver.api._

val db = Database.forConfig("db")
val query = sql"""select ID from TEACHER""".as[String] 
val people = db.withSession{ implicit session =>
Ok(query.list)