How to specify type using sql template
I'm using this piece of code
to create a query like this
There is a few problems with it, I guess because this is a parameterized query and parameters are used as literals (need confirmation on this)?
to create a query like this
There is a few problems with it, I guess because this is a parameterized query and parameters are used as literals (need confirmation on this)?
- I have to cast
temp.idto integer in each subquery, otherwise I getPostgresError: operator does not exist: integer = text. I don't know how that affects performance, but it feels dirty. - The query results are of type
string, which I then have to cast again. - Also, since the whole query is of type
SQL<unknown>, when parsing the result I need to force the wrong/unwanted typestringonto the typescript compiler first, just to be able to cast the value, like thisresult.map( v => +(v.id as string) )
param method in drizzle but no docs and no idea how to use it or if it could be useful anyhow. Please enlighten me.