drizzle-team / drizzle-team/drizzle-orm

[BUG]: postgres.js adapter not converting Date object

Open
#3,108 3 comments 7 reactions 0 assignees View on GitHub
bug db/postgres driver/postgresjs priority qb/crud
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### What version of `drizzle-orm` are you using?

0.34.1

### What version of `drizzle-kit` are you using?

_No response_

### Describe the Bug

Using postgres.js, any input value of Date object is not automatically converted to string.

```
TypeError [ERR_INVALID_ARG_TYPE]ng" argument must be of type string or an instance of Buffer or ArrayBuffer. Received an instance of Date
at Function.byteLength (https://deno.land/std@0.132.0/node/_buffer.mjs:388:11)
at Function.str (https://deno.land/x/postgresjs@v3.4.4/src/bytes.js:23:27)
at https://deno.land/x/postgresjs@v3.4.4/src/connection.js:941:16
at Array.forEach ()
at Bind (https://deno.land/x/postgresjs@v3.4.4/src/connection.js:931:16)
at prepared (https://deno.land/x/postgresjs@v3.4.4/src/connection.js:207:7)
at ParameterDescription (https://deno.land/x/postgresjs@v3.4.4/src/connection.js:610:58)
at handle (https://deno.land/x/postgresjs@v3.4.4/src/connection.js:477:6)
at data (https://deno.land/x/postgresjs@v3.4.4/src/connection.js:318:9)
at https://deno.land/x/postgresjs@v3.4.4/polyfills.js:138:30 {
code: "ERR_INVALID_ARG_TYPE",
name: "TypeError",
toString: [Function (anonymous)]
}
```

It should be manually converted to string by toISOString() or similar.

### Expected behavior

This is only happening using postgres.jsa adapter, not seeing this issue with pg/node-postgres.

### Environment & setup

Deno 2.0 macosx

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.