Argument of type 'RawBuilder<unknown>' is not assignable to...
I have a query that looks like this:
countQuery.where(
'activityId',
'in',
sql
(SELECT activityId FROM activities WHERE MATCH(EL_EQ_PRODUCT_DESCRIPTION) AGAINST (+"${value}" IN BOOLEAN MODE))
,
);
TypeScript is now showing an error that states:
Argument of type 'RawBuilder<unknown>' is not assignable to parameter of type 'OperandValueExpressionOrList<Database, "activities", "activityId">'.
This is with Kysely 0.27.0/0.27.1/0.27.2 and TypeScript 5.3.3
Can anyone explain what's going on here please?3 Replies
Did you read the release log? You need to give a type for the raw expression.
By the way, that query is broken anyways. In this part:
${value}
gets compiled into a placeholder string like $1
or ?
or @1
depending on the dialect. So your query matches something agains a string "+$1"
Solution
What you actually want is something like this
I did but it didn't register with me for some reason, apologies
Types are once again a little bit stricter in some places. You might get type errors from code like where('first_name', '=', sql
something). You need to explicitly give a type for sql expressions like this sql<string>
something
The query does work, however.
In that it returns the correct results
Your recommendation for the query fails with InvalidArgument, I've reverted as the original works. Providing <number> the sql worked a treat though. Thank you