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?
The Plain SQL API allows a developer to run any SQL statement onto the database. Even though specifying parameter values is easy and straightforward, it doesn't stop a developer to embed a value directly into the SQL statement instead of using parameters.
The GROUP BY statement groups rows that have the same values into summary rows, like "find the number of customers in each country". The GROUP BY statement is often used with aggregate functions ( COUNT() , MAX() , MIN() , SUM() , AVG() ) to group the result-set by one or more columns.
Slick is an advanced, comprehensive database access library for Scala with strongly-typed, highly composable APIs. Slick makes it easy to use your database in a way that's natural to it.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With