denodrivers / denodrivers/postgres

Support Set as bind parameter

Open
#477 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
655
Forks
97
PR merge metrics
No merged PRs in 30d

Description

**Is your feature request related to a problem? Please describe.**

I tried to pass a `Set` as a bind parameter, expecting it to behave like `Array`. It was hard to debug since the query gave wrong results, not an error.

**Describe the solution you'd like**

Support `Set` just like `Array`: convert it to a Postgres array.

**Additional context**

Set:

```console
$ deno eval 'import { Client } from "https://deno.land/x/postgres@v0.19.3/mod.ts"; const client = new Client({}); await client.connect(); const odds = new Set([1,3,5]); const result = await client.queryObject`SELECT 3=ANY(${odds}) AS should_be_true`; console.log(result.rows);'
[ { should_be_true: false } ]
```

Array:

```console
$ deno eval 'import { Client } from "https://deno.land/x/postgres@v0.19.3/mod.ts"; const client = new Client({}); await client.connect(); const odds = new Array([1,3,5]); const result = await client.queryObject`SELECT 3=ANY(${odds}) AS should_be_true`; console.log(result.rows);'
[ { should_be_true: true } ]
```

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.