I'm struggling on appending additional conditions to my query. In its simplest form, what I need is something like below:
def findPeople(name: String, maybeSurname: Option[String]) = {
val sql1 = sql"select * from my_table where name = $name"
val sql2 = maybeSurname.map( surname => sql"and col2 = $surname" ).getOrElse(sql"")
val finalSql = sql1 + sql2 // I need this kind of feature
...
...
}
Using #$ could be an option, but then surname wouldn't be a bind variable, which is a big issue.