postgres
postgres copied to clipboard
Dynamic queries not working properly
Hello, I am trying to implement query fragments as described in your dynamic query section. I have the following:
const results = await sql`
SELECT
*
FROM
schema.table
WHERE
shorts_availabilities && ARRAY[${body.timespan}]::date[]
${body.areas !== 0 ? sql`AND areas && ARRAY[${body.area}]::INTEGER[]` : sql``}
`
I get a syntax error at "AND"
I think you might need to change && to AND