Closed ManuelTS closed 4 months ago
@ManuelTS Postgres doesn't allow to dynamically craft table names as seen here: https://github.com/brianc/node-postgres/issues/1426
What you could do, if you're 100% sure the table name comes from your code and not user input:
sql.query(`DELETE FROM ${KEY_QUOTES};`);
Or use something like pg-format https://stackoverflow.com/a/51154958/147079
Thanks!
Documentation: https://node-postgres.com/features/queries#parameterized-query
Thanks for the tip, now it works @vvo. I got this from
https://vercel.com/docs/storage/vercel-postgres/quickstart#preparing-your-local-project
so their documentation is utterly wrong on that subject. They use the sql
method with string templates all the time in there.
I get
when I use this simple code in an nuxt API endpoint
and my setup is
When I change the const in the string template to the const value as in
it works as it should