drizzle-team / drizzle-team/drizzle-orm

[BUG]: incorrect types for execute with pglite

Open
#3,975 6 comments 5 reactions 0 assignees View on GitHub
bug bug/cant-reproduce driver/pglite priority qb/crud
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### Report hasn't been filed before.

- [x] I have verified that the bug I'm about to report hasn't been filed before.

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

0.38.2

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

0.30.1

### Other packages

@electric-sql/pglite@0.2.9,@types/pg@8.10.2,pg@8.7.3

### Describe the Bug

When using

```ts
const result = db.execute(sql`select 8 as a_number`)
```

the return type is declared as `postgres.RowList<{ a_number: number; }[]>`.

But when using pglite, the actual `result` is

```ts
Object {
"affectedRows": 0,
"fields": Array [
Object {
"dataTypeID": 21,
"name": "a_number",
},
],
"rows": Array [
Object {
"a_number": 8,
},
],
}
```

I'm not yet sure _where_ this bug exists. It may be in pglite or @types/pg.

Here's how we're setting up pglite with Drizzle per [these docs](https://orm.drizzle.team/docs/connect-pglite#step-2---initialize-the-driver-and-make-a-query):

```ts
// test-db.ts

import { PGlite } from '@electric-sql/pglite';
import { drizzle } from 'drizzle-orm/pglite';

const client = new PGlite({
extensions: { uuid_ossp },
debug: 0,
database: 'testdb',
username: 'postgres',
});

export const db = drizzle(client); // also tried drizzle({ client })
```

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.