在 Slick 中查看 SQL 查询 [英] View SQL query in Slick
本文介绍了在 Slick 中查看 SQL 查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法观察由Query
生成的SQL语句?
例如,我有这个:val q = actions.filter(v => v.actionHash === hash && v.carriedAt > past)
我可以查看其底层原始 SQL 吗?
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:
您可以打印 Slick 文档中所示的查询语句一个>:
val invoker = q.invoker
val statement = q.selectStatement
对于其他类型的语句,请查看 insertStatement
、deleteStatement
和 updateStatement
.
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)
文档.
这篇关于在 Slick 中查看 SQL 查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文