Skip to content

Dynamic SQL with an array variable in a DuckDB 'IN'? #1088

Answered by Fil
mskullcap asked this question in Q&A
Discussion options

You must be logged in to vote

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"
  })`
])

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mskullcap
Comment options

Answer selected by mskullcap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants