I am building a small API using Javalin & Exposed ORM. I'm trying to use the regex where condition but an exception is thrown because the SQL query performed due to my code seems to be incomplete (the pattern is missing).
fun getUsersByFilter(filter: String): List<User> {
val regex = StringBuilder("/")
.append(filter.toLowerCase())
.append("/i")
.toString()
/**
* The .regexp(someString) method take a string as argument (a pattern)
*/
val users = transaction {
User.find{ Users.pseudo.regexp(regex) }.toList()
}
return users
}
Position : 141. Statement(s): SELECT users.id, users.pseudo, users.email, users."password", users.admin, users.created_at, users.updated_at FROM users WHERE users.pseudo REGEXP ?
org.jetbrains.exposed.exceptions.ExposedSQLException: org.postgresql.util.PSQLException: ERREUR: erreur de syntaxe sur ou près de « REGEXP »
Position : 141
SQL: [SELECT users.id, users.pseudo, users.email, users."password", users.admin, users.created_at, users.updated_at FROM users WHERE users.pseudo REGEXP ?]
Can someone help me please?