-
I am struggling to generate dynamic sql for array values. The SQL I want to generate should look like this: SELECT * FROM events
WHERE name IN ('Sputnik 1', 'Apollo 11') and if I put this in a sql template, it works. The challenge I have is if I define the values as an array and then try to run the SQL generated from the array: const sc = ["Sputnik 1", "Apollo 11"] SELECT * FROM events
WHERE name IN (${sc.join(",")}) I just can't get this sql to work. If I put |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
this is not yet supported (by DuckDB) duckdb/duckdb-wasm#447 the way around it is to do your own escaping; something like: sql([
`SELECT x, y FROM t WHERE x IN (${
selection.length
? selection.map((d) => `'${d.replaceAll("'", "''")}'`)
: "NULL"
})`
]) |
Beta Was this translation helpful? Give feedback.
this is not yet supported (by DuckDB) duckdb/duckdb-wasm#447
the way around it is to do your own escaping; something like: