I would like to translate an SQL query into a TableQuery:
SELECT ..., TRIM(LEADING '0' FROM mycolumn) FROM mytable WHERE TRIM(LEADING '0' FROM mycolumn) = '$key
Should become MyTableQuery.filter(<_.mycolumn something something> )
I cannot use an implicit MappedColumnType because I am mapping from String to String and have other String columns in the result. And I have no idea how I would use it in both SELECT and WHERE
For the SELECT part, I have created a custom function for mapping the result tuples to my case class, so I only need a solution for the WHERE part.
Have read the Coming from SQL and User defined features from the docs but unfortunately, I am none the wiser. I suppose I could use a SimpleFunction.unary[String, String] but have not figured out how.
I would trim a regular String with dropLeft, however Rep[String] does not have such a method. ltrim does not accept a parameter. endsWith is ambiguous in my case.
I cannot pad my query String, since not all values in the DB are padded and have different lengths.
I definitely can use plain SQL and map the results, but I would really like to understand what I am missing here.
I am using Slick 3.1.1