duckdb / duckdb/duckdb-node

Prepared statements don't accept list arguments

Open
#38 3 comments 3 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
91
Forks
36
PR merge metrics
No merged PRs in 30d

Description

I can't pass a list/array as an argument into prepared statements with duckdb-node 0.9.2. Try this script:
```javascript
const { Database } = require("duckdb");

const db = new Database(":memory:");
const conn = db.connect();

const stmt1 = conn.prepare("select ?::INTEGER as fortytwo");
stmt1.all(42, (err, res) => {
if (err) {
throw err;
}
console.log(res);
});

// throws error
const stmt2 = conn.prepare("select unnest(?::VARCHAR[]) as x");
stmt2.all(["a", "b", "c"], (err, res) => {
if (err) {
throw err;
}
console.log(res);
});

// throws error
const stmt3 = conn.prepare("select unnest(?) as x");
stmt3.all(["a", "b", "c"], (err, res) => {
if (err) {
throw err;
}
console.log(res);
});

// throws error
const stmt4 = conn.prepare("select unnest(?) as x");
stmt4.all([["a", "b", "c"]], (err, res) => {
if (err) {
throw err;
}
console.log(res);
});
```
Depending on which version you try, you get errors like:
```
Error: Type VARCHAR with value 'a,b,c' can't be cast to the destination type LIST
```
or
```
Error: Binder Error: UNNEST() can only be applied to lists, structs and NULL
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.