Report hasn't been filed before.
What version of drizzle-orm are you using?
0.45.2
What version of drizzle-kit are you using?
0.31.10
Other packages
No response
Describe the Bug
What is the undesired behavior?
drizzle-kit pull crashes with a TypeError: Cannot read properties of null (reading 'camelCase') when introspecting a MySQL 8+ database that contains a unique functional/expression index.
In MySQL 8, when an index is created using an expression (e.g., CREATE UNIQUE INDEX idx ON table ((CASE WHEN col = 1 THEN 1 ELSE NULL END))), the COLUMN_NAME field in INFORMATION_SCHEMA.STATISTICS returns NULL. Instead, the actual expression is stored in the EXPRESSION column.
Currently, mysqlSerializer.ts unconditionally pushes COLUMN_NAME into the index constraints. Later, during TS generation in introspect-mysql.ts, casing(null) is called, crashing the CLI.
What are the steps to reproduce?
I have created a minimal reproduction repository for this issue:
[Replicated error]
(https://github.com/danielcuque/mysql_drizzle)
- Clone the repo and run
pnpm install
- Run
pnpm run db:up to start the MySQL container.
- Run
pnpm run repro:index (which targets a table with a functional index).
- (Assuming the silent crash bug is patched locally) You will see the
TypeError originating from createTableUniques in introspect-mysql.ts.
What is the desired result?
Drizzle should extract the EXPRESSION column from INFORMATION_SCHEMA.STATISTICS when COLUMN_NAME is null. It should flag these columns in the internals object, and the TS generators should output them wrapped in sql\...`` instead of crashing.

Report hasn't been filed before.
What version of
drizzle-ormare you using?0.45.2
What version of
drizzle-kitare you using?0.31.10
Other packages
No response
Describe the Bug
What is the undesired behavior?
drizzle-kit pullcrashes with aTypeError: Cannot read properties of null (reading 'camelCase')when introspecting a MySQL 8+ database that contains a unique functional/expression index.In MySQL 8, when an index is created using an expression (e.g.,
CREATE UNIQUE INDEX idx ON table ((CASE WHEN col = 1 THEN 1 ELSE NULL END))), theCOLUMN_NAMEfield inINFORMATION_SCHEMA.STATISTICSreturnsNULL. Instead, the actual expression is stored in theEXPRESSIONcolumn.Currently,
mysqlSerializer.tsunconditionally pushesCOLUMN_NAMEinto the index constraints. Later, during TS generation inintrospect-mysql.ts,casing(null)is called, crashing the CLI.What are the steps to reproduce?
I have created a minimal reproduction repository for this issue:
[Replicated error]
(https://github.com/danielcuque/mysql_drizzle)
pnpm installpnpm run db:upto start the MySQL container.pnpm run repro:index(which targets a table with a functional index).TypeErrororiginating fromcreateTableUniquesinintrospect-mysql.ts.What is the desired result?
Drizzle should extract the
EXPRESSIONcolumn fromINFORMATION_SCHEMA.STATISTICSwhenCOLUMN_NAMEis null. It should flag these columns in theinternalsobject, and the TS generators should output them wrapped insql\...`` instead of crashing.