Skip to content

[BUG]: drizzle-kit introspection fails with "Cannot read properties of undefined (reading 'replace')" due to case sensitivity in column names #4888

@0xMilord

Description

@0xMilord

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?

0.44.5

What version of drizzle-kit are you using?

0.31.4

Other packages

No response

Describe the Bug

Bug Description

When running drizzle-kit introspect on a PostgreSQL database, the command fails with:

Root Cause

The issue is in bin.cjs around line 19554 where the code expects column names in uppercase but receives them in lowercase from the database.

Current problematic code:

const constraintName = checkConstraintRow["CONSTRAINT_NAME"];
const constraintValue = checkConstraintRow["CHECK_CLAUSE"];
const tableName = checkConstraintRow["TABLE_NAME"];

Working fix:

const constraintName = checkConstraintRow["CONSTRAINT_NAME"] ?? checkConstraintRow["constraint_name"];
const constraintValue = checkConstraintRow["CHECK_CLAUSE"] ?? checkConstraintRow["check_clause"];
const tableName = checkConstraintRow["TABLE_NAME"] ?? checkConstraintRow["table_name"];

Environment

  • drizzle-kit version: 0.31.4
  • Database: PostgreSQL (Supabase)
  • OS: Windows 10

Steps to Reproduce

  1. Run npx drizzle-kit introspect on a PostgreSQL database with check constraints
  2. The command fails when processing check constraints

Expected Behavior

The introspection should complete successfully and generate schema files.

Additional Notes

This appears to be a case sensitivity issue where different PostgreSQL configurations return column names in different cases.

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