PrismaP
Prisma9mo ago
1 reply
François

Typed Query parameters not generated

Hey community,
I am trying out the typed query feature and run into a problem that might also be faulty usage by me.
I got the following raw query file:
-- @param {String} $1:text
-- @param {Int} $2:limit
DO $$
BEGIN
    IF NOT EXISTS (
        SELECT 1
        FROM pg_extension
        WHERE extname = 'fuzzystrmatch'
    ) THEN
        CREATE EXTENSION fuzzystrmatch SCHEMA matching;
    END IF;

SELECT 
*, levenshtein(name, $1) AS distance
FROM "matching"."skills"
ORDER BY distance ASC
LIMIT $2;
END
$$;


As you can see I defined the parameter manually. I did generate the client and try to call it like this:
return this.database.client.$queryRawTyped(getNearestSkillWithoutType(), name)


TS complains about the name argument provided in the $queryRawTyped call. Providing it int the getNearestSkillWithoutType call also results in a TS error complaining about the extra argument.
The documentation is kinda weird too. In the documentation text it says:
When using the generated function in your TypeScript code, pass the arguments as additional arguments to $queryRawTyped


but the code example provides the arguments in the query call.

But my generated client doesnt accept any of those two scenarios. It knows about the query but not about their arguments.

Am I missing something?
Was this page helpful?