I’m attempting to follow the example for SQL interpolation in the ScalikeJDBC library. Here’s the code snippet I’m working with:
val userRecord = sql"select id, name from users where id = ${userId}"
println(userRecord.statement)
However, the output I receive is unexpected:
select id, name from users where id = ?
What could be the issue here?
EDIT and SOLUTION:
Upon further inspection, I realized the confusion arose from printing the SQL query without verifying its correctness. I needed to use SQLSyntax.createUnsafely
with the string designated for interpolation.