How do I specify a MySQL index hint?
Hi, I am trying to build the following query (as a CTE, as part of a larger query), but I can not work out how I can pass the index hint (
USE INDEX ...
):
I tried using raw sql:
but I get typescript error:
I can get it to work if I build the whole complete query with sql`...`
, but that brings about other issues such as how to use .stream()
instead of sql`...`.execute(db)
Any clues?3 Replies
OK, I guess this is not possible in kysely. I solved it by creating a view on the server, which makes the kysely code a lot simpler!
Many thanks for a great bit of software!
It's possible. You just need to provide the row type explicitly. Kysely can't parse types from raw SQL.
https://kyse.link/qD6b7
Thank you, and apologies for my impatience!
Unfortunately the generated SQL in not correct (for MySQL), or at least I can't get it to work.
With the example in your link:
produces:
however I think it needs to be:
I can add the parentheses in the sql`` call, but adding the alias in there too causes typescript to have a fit (No overload matches this call.)
Am I missing something?
TIA