Re:Migrating to Postgres
by vvpan on Wednesday May 14, 2025 @11:58PM
(#43991716)
How do you do typed raw queries?
[ Parent
| on HN ]
Re:Migrating to Postgres
by campbellmorgan on Thursday May 15, 2025 @03:10AM
(#43992566)
https://www.prisma.io/docs/orm/prisma-client/using-raw-sql/r... - it assumes that these queries return arrays and there's a template you can pass in like this:
prisma.$queryraw<YourType>`SELECT * FROM ...`
Oh, just manual template typing. That's not great. We've done that and it is error-prone. A SQL-generator infers the types from the query, for example.
Re:Migrating to Postgres
by Tadpole9181 on Thursday May 15, 2025 @04:42PM
(#43999143)
That's the raw, raw querying. They provide a TypedSQL system where you write SQL and it automatically generated the parameter and return types. It's in the docs.
Check out the docs https://www.prisma.io/docs/orm/prisma-client/using-raw-sql/t... it generates output types, though input types still need to be done by you via type comments in the sql