Slick 3.1 - 从 DBIOAction 打印 SQL(插入语句) [英] Slick 3.1 - Printing SQL from DBIOAction (insert statements)

查看:55
本文介绍了Slick 3.1 - 从 DBIOAction 打印 SQL(插入语句)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Slick 3.1 中,随着新 API 的完全重新设计,在执行插入操作时似乎无法查看生成的 SQL 语句.

In Slick 3.1, with the complete redesign of the new API, it seems to be impossible to view the generated SQL statements when doing an insert.

如果你有这样的事情

val action = DBIO.seq(
  SomeTables ++= Seq(TableData(1,"First"),TableData(2,"Second"))
)

您似乎实际上无法从 action 看到生成的 SQL.result 方法实际上并不存在,并且 statements 的变体只是打印 ? 代替实际值,如果您不使用 DBIO.seq,如果您使用的是 DBIO.seqstatements 方法实际上并不存在.

It doesn't seem you are actually able to see the generated SQL from the action. The result method doesn't actually exist, and variations of statements just print ? in place of the actual values if you don't use DBIO.seq, if you are using DBIO.seq the statements method doesn't actually exist.

即使使用诸如 .transactionally.withPinnedSession 之类的方法,它似乎也没有什么区别(但是我不知道这应该如何帮助).

Even when using methods such as .transactionally or .withPinnedSession, it doesn't seem to make a difference (however I don't know how this should help).

从所有的方法来看,这似乎是不可能的?

From observation of all of the methods, it appears that this is impossible?

推荐答案

这不是由 Slick 3.1 处理的,您可以查看 源代码,但您可以在 Slick 3.2 版本中使用此功能.

This is not handle by Slick 3.1 you can see the source code, but you can get this feature available into Slick 3.2 version.

如果你有一个更大的代码库 &在这种情况下无法升级到 3.2,您只需添加 此提交 3.1 源代码,构建 &用它.确保导入提交所需的必要内容.

If you a have a larger code base & can't upgrade to 3.2 in that case you can just add this commit to 3.1 source code, build & use it. Make sure you import the necessary things required for the commit.

这篇关于Slick 3.1 - 从 DBIOAction 打印 SQL(插入语句)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆