Slick 3.1 - Printing SQL from DBIOAction (insert statements)
Asked Answered
S

1

16

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.

If you have something like this

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

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.

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?

Seabrooke answered 14/10, 2015 at 12:8 Comment(4)
Same here, tried to find a way to print the sql from DBIOAction but with no luck. Hope someone here point us towards correct direction. It prints "?" because it is defaulting to Prepared Statement?Goatfish
what database are you using ?Untune
there is a way in the documentation : slick.lightbend.com/doc/3.0.0/queries.html#queryingUntune
New feature added to 3.2. and then add to log4j this is working as expected.Besant
B
1

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.

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.

Besant answered 6/2, 2020 at 9:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.