Reputation: 33439
I am trying to print an interpolated Slick2 SQL statement for debugging and all I get is the one with question marks e.g.
def query(name: String) = sql"SELECT MAX(age) FROM users WHERE name = $name".as[Int]
println(query("Bob").getStatement)
The above prints this:
SELECT MAX(age) FROM users WHERE name = ?
How can I make it print this:
SELECT MAX(age) FROM users WHERE name = 'Bob'
Note: This questions is NOT a duplicate of this
Upvotes: 12
Views: 2928
Reputation: 1179
You probably want to add the following to your application.conf
logger.scala.slick.session=DEBUG
This should show compiled query strings in the console.
Upvotes: 5
Reputation: 17933
From the slick documentation: "You can use #$ instead of $ to get the literal value inserted directly into the query".
//note the '#'
def query(name : String) = sql"SELECT MAX(age) FROM users WHERE name = '#$name'".as[Int]
Upvotes: 3