drizzle-team / drizzle-team/drizzle-orm
[BUG]: null is not an object (evaluating 'row[columnIndex]')
- 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?
1.0.0-beta.22
### What version of `drizzle-kit` are you using?
1.0.0-beta.22
### Other packages
-
### Describe the Bug
#### What is the undesired behavior?
Using db.select() a PostgreSQL table crashes with `TypeError: null is not an object (evaluating 'row[columnIndex]')` inside mapResultRow in drizzle-orm/utils.js. This happens consistently on every query against the affected table, even with explicit column selection.
Additionally, when using timestamp({ mode: "string" }) columns, a secondary crash occurs in mapFromDriverValue with `TypeError: undefined is not an object (evaluating 'value.toISOString')`
#### What are the steps to reproduce it?-
- Define a pgTable with text() columns (used for datetime storage)
```typescript
export const admin_sessions = pgTable(
"admin_sessions",
{
id: text()
.primaryKey()
.$defaultFn(() => crypto.randomUUID()),
admin_user_id: text()
.notNull()
.references(() => admin_users.id, { onDelete: "cascade" }),
token: text().notNull().unique(),
expires_at: text().notNull(),
created_at: text().notNull().default(sql`now()`),
ip_address: text(),
user_agent: text(),
},
(t) => [
index("idx_admin_sessions_token").on(t.token),
index("idx_admin_sessions_user_id").on(t.admin_user_id),
],
);
```
- Run DB
```typescript
async getByToken(token: string): Promise {
try {
const result = await db
.select()
.from(admin_sessions)
.where(eq(admin_sessions.token, token))
.limit(1);
return result[0];
} catch (ex) {
console.error(ex);
throw ex;
}
}
```
#### What is the desired result?
db.select() should return mapped rows correctly without crashing.
##### Additional context:
- Database engine: PostgreSQL
- Driver: bun:sql
- Runtime: bun@1.3.13
- Drizzle version: 1.0.0-beta.22
- Monorepo: Yes
Contributor guide
Assessment
This issue has not been assessed yet.