Advice on building plugin for working with parameters

ISIvan Shadrin4/27/2023
I am currently working on a driver for YDB
YDB dialect expects query parameters to be explicitly declared as a part of the query using DECLARE statement (reference )

I want to build a custom plugin that would automatically add DECLARE statements for each parameter in query

Take a look at the following example query

Expected output would be:
DECLARE $1 AS String; DECLARE $2 AS String; DECLARE $3 AS String; SELECT "id", "last_name" FROM "user" WHERE "id" IN ($1, $2, $3)
*Please ignore type differences between native JS objects and database types. This is out of the scope of the question.

I have checked as reference and read documentation but could not figure out how I could access query parameters from OperationNodeTransformer instance.

Could you please give me some advice?
Hey 👋

I had a similar constraint when creating the surreal db dialect
Had to prepend a bunch of let statements before the main query
if this is possible in YDB, it'll be easier than altering the AST
and better ergonomically than forcing a plugin on consumers
in general, Kysely's parameters sit in ValueNode and other ValueX nodes
ISIvan Shadrin4/27/2023
Thanks a lot!