Inquiry with a similar proposal in scalikejdbc

Can someone please give me an example of how to use as clause in scalikejdbc with dynamic value. I used the following query, but it did not work.

 sql"select * from tables_list where lower(TABLE_NAME) like '%$tableName.toLowerCase%'"
+4
source share
1 answer

scalikejdbc build in preventing SQL injection, so when you type like '%$tableName.toLowerCase%'it displays as like '%'urValue'%', so an error occurs.

I found a way to figure out what

def search(name:String){
    val searchName = s"%$name%"
    DB readOnly{ implicit session =>
        sql"select * from db where name like $searchName".map
    ...
    ...
}

I hope this can help you.

+2
source

Source: https://habr.com/ru/post/1663152/


All Articles