MATCH AGAINST Syntax
See original GitHub issueThis is such a good library and amazing use of TypeScript inference.
The challenge I have is that I need to be able to issue a query that includes MATCH AGAINST for a field that is indexed as FULLTEXT but can’t seem to figure out the safe, correct syntax.
I can do it like this:
query.where(sql`MATCH(the_field_name) AGAINST (${someValue} IN NATURAL LANGUAGE MODE)`);
However, I rather this was parameterised, something like this:
query.where(sql`MATCH(the_field_name) AGAINST (? IN NATURAL LANGUAGE MODE)`, '=', someValue);
The latter example builds a query that looks like:
where MATCH(EL_Notes_Dispo) AGAINST (? IN NATURAL LANGUAGE MODE) = ?
Whereas I’d like for the ? placeholder to be substituted. Is there some syntax that I can use in Kysely to achieve this?
(P.S. I’d love to join the Discord to ask this kind of question but the chat link on Github shows an invitation expired error)
Issue Analytics
- State:
- Created a year ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
Your first example IS parametrized. Just take a look at the generated SQL. The
sql
template tag takes care of the parametrization. It doesn’t actually interpolate the value into the SQL.Perfect - that worked, thank you