문제

Is there a way to observe an SQL statement that will be generated by Query?
For example, I have this:
val q = actions.filter(v => v.actionHash === hash && v.carriedAt > past)
Can I view its underlying raw SQL?

도움이 되었습니까?

해결책

Slick 2.X:

You can print the query statement as shown on the Slick documentation:

val invoker = q.invoker
val statement = q.selectStatement

For other type of statements look at insertStatement, deleteStatement and updateStatement.

Slick 3.X:

val res = table.filter(_.id === 1L).result
res.statements.foreach(println)

Docs.

다른 팁

For slick 3.0

println(sortedQuery.result.statements.headOption)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top