drizzle-team / drizzle-team/drizzle-orm
[BUG]:Deno postgres Rows return undefined in Drizzle Remote Executor
- 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.45.1
### What version of `drizzle-kit` are you using?
NA
### Other packages
postgres@3.4.7
### Describe the Bug
Undesired behavior:
When using drizzle-orm/pg-proxy with Deno and the postgres client, all fields in query results returned via the Remote Executor are undefined. Spreading the row ({ ...row }) or calling row.toJSON() does not work in Deno, so Drizzle receives objects where every property is undefined.
Steps to reproduce:
Use Deno with postgres client and drizzle-orm/pg-proxy.
Define a simple table, e.g., users with columns id, name, email, etc.
Set up a Remote Executor like this:
```
const executor = async (sql: string, params: unknown[] = []) => {
const result = await client.unsafe(sql, params as any[]);
const rows = result.map(row => ({ ...row })); // this does not work in Deno
return { rows };
};
```
Perform a query: db.select().from(users).
Observed result:
```
[
{
"id": undefined,
"name": undefined,
"email": undefined,
"bio": undefined,
"createdAt": undefined,
"updatedAt": undefined
}
]
```
Desired result:
An array of plain JavaScript objects with correct field values, e.g.:
```
[
{
"id": 1,
"name": "John Doe",
"email": "john@example.com",
"bio": "Test user",
"createdAt": "...",
"updatedAt": "..."
}
]
```
Additional Information
Database engine: PostgreSQL 15
Driver: Deno postgres client (https://deno.land/x/postgres
)
Runtime: Deno 1.40+
Issue specific to runtime: Yes, row.toJSON() and { ...row } work in Node.js but not in Deno.
Workaround: Convert rows manually using row.keys() and row.get(key):
```
const rows = result.map(row => {
const obj: Record = {};
for (const key of row.keys()) {
obj[key] = row.get(key);
}
return obj;
});
```
Typescript version: N/A (Deno uses built-in TS)
Monorepo: No
[deno.json](https://github.com/user-attachments/files/24543592/deno.json)
`
import postgres from "postgres";
import { drizzle } from "drizzle-orm/pg-proxy";
import { pgTable, serial, varchar, text, timestamp } from "drizzle-orm/pg-core";
export const users = pgTable("users", {
id: serial("id").primaryKey(),
name: varchar("name", { length: 100 }).notNull(),
email: varchar("email", { length: 255 }).notNull().unique(),
bio: text("bio"),
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").defaultNow().notNull(),
});
const client = postgres({
host: "localhost",
port: 5432,
username: "postgres",
password: "123456",
database: "postgres",
max: 10,
idle_timeout: 60,
connect_timeout: 10,
max_lifetime: 3600,
});
const executor = async (sql: string, params: unknown[] = []) => {
const result = await client.unsafe(sql, params as any[]);
return { rows: result };
};
const db = drizzle(executor as any, { schema: { users } });
(async () => {
try {
console.log("Querying all users...");
const allUsers = await db.select().from(users);
console.log(allUsers);
} catch (err) {
console.error("Error:", err);
} finally {
await client.end();
}
})();
`
Contributor guide
Research direction
Start at the drizzle-orm/pg-proxy remote executor path and reproduce the Deno setup with the postgres client described here. Compare how returned rows are passed through in Deno versus Node.js, using the reported row.keys() and row.get(key) behavior as the reference. Done means db.select().from(users) returns populated plain objects rather than undefined field values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- deno, postgres, postgresql, typescript
- Domain
- backend, database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100