$if with sql.raw doesn't compile
Hey,
I have updated my kysely version after I deleted node_modules and npm installed and I am getting an error for the following code:
const filterWhereQuery = sql.raw(
LOWER("${dimensionName}") LIKE '%${filter?.toLowerCase()}%');
The error in at the 1st if where there is suddenly a type problem:
Argument of type 'RawBuilder<unknown>' is not assignable to parameter of type 'ExpressionOrFactory<any, ${string}.${string}
, SqlBool>'.
Property 'isSelectQueryBuilder' is missing in type 'RawBuilder<unknown>' but required in type 'SelectQueryBuilderExpression<Record<string, SqlBool>>'
what can I do to fix this quickly that doesn't require a huge change ? 2 Replies
Solution
Hey 👋
Try providing
<SqlBool>
generic to your sql
template tag.I explicitly set the type to the filterWhereQuery and it worked
RawBuilder<SqlBool>