Open waimun opened 1 month ago
bumping this issue
I had the same issue, but found it. If you leave out the parenthesis it works.
const ids = ['ab11cd', 'ef22gh']
await sql`
select student_id, max(version) as version
from students
where student_id in ${sql(ids)}
group by student_id`
If parenthesis is used, should the query be flagged as a syntax error or self correct itself?
Consider the following code:
This would result in the following error in the Postgres database (using 16.3-bookworm currently).
I tried various syntax usages from the guide, section "Building queries" (README) but I was not able to achieve a non-error from the database. As a temporarily workaround, I have to create a formatted string with a single quote (instead of double quote) for each value in the array (ids), and then use that to pass as sql.unsafe().
Note: Postgres interprets double quote as a column or table name.
Please investigate, and advise if there's something wrong with the usage above.