Skip to content

[BUG]: null is not an object (evaluating 'row[columnIndex]') #5708

@Richie-Z

Description

@Richie-Z

Report hasn't been filed before.

  • 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)
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
    async getByToken(token: string): Promise<AdminSessionModel | undefined> {
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions