porsager / postgres

Postgres.js - The Fastest full featured PostgreSQL client for Node.js, Deno, Bun and CloudFlare
The Unlicense
7.04k stars 257 forks source link

syntax error at or near "$1" #808

Closed kquadri closed 4 months ago

kquadri commented 4 months ago

Hello. I'm trying to make a dynamic request. but I'm getting this error "PostgresError: syntax error at or near "$1"". Can you tell me what I'm doing wrong?

const query = 'SELECT 1'; const result = await sql `${query}`

porsager commented 4 months ago

Postgres.js uses tagged templates to ensure you don't create unsafe queries from strings. I really hope the documentation should cover all this, so would you mind giving that a read again, and then if it still doesn't make sense reopen this issue, and we can look at what's missing?