From da2c068b51bac246ffe7d2ed6c40c1c91db4cbd3 Mon Sep 17 00:00:00 2001 From: jaydeep-pipaliya <71074587+jaydeep-pipaliya@users.noreply.github.com> Date: Thu, 2 Apr 2026 12:16:12 +0530 Subject: [PATCH] fix: skip MySQL expression indexes with null COLUMN_NAME during introspection drizzle-kit pull crashes with TypeError: Cannot read properties of null (reading 'camelCase') when introspecting a MySQL 8+ database that contains functional/expression indexes. In MySQL 8+, expression indexes (e.g. CREATE UNIQUE INDEX idx ON t ((CASE WHEN col = 1 THEN 1 ELSE NULL END))) store NULL in the COLUMN_NAME field of INFORMATION_SCHEMA.STATISTICS. The serializer pushed this null value into the columns array, and later the casing function crashed trying to call .camelCase() on null. Skip index rows where COLUMN_NAME is null since Drizzle doesn't support expression indexes yet. This prevents the crash while allowing normal column-based indexes to be introspected correctly. Fixes #5546 --- drizzle-kit/src/serializer/mysqlSerializer.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drizzle-kit/src/serializer/mysqlSerializer.ts b/drizzle-kit/src/serializer/mysqlSerializer.ts index 322d8957f8..1293f3c1d5 100644 --- a/drizzle-kit/src/serializer/mysqlSerializer.ts +++ b/drizzle-kit/src/serializer/mysqlSerializer.ts @@ -862,12 +862,16 @@ export const fromDatabase = async ( const tableSchema = idxRow['TABLE_SCHEMA']; const tableName = idxRow['TABLE_NAME']; const constraintName = idxRow['INDEX_NAME']; - const columnName: string = idxRow['COLUMN_NAME']; + const columnName: string | null = idxRow['COLUMN_NAME']; const isUnique = idxRow['NON_UNIQUE'] === 0; const tableInResult = result[tableName]; if (typeof tableInResult === 'undefined') continue; + // MySQL 8+ functional/expression indexes have COLUMN_NAME = NULL. + // Skip these since Drizzle doesn't support expression indexes yet. + if (columnName === null) continue; + // if (tableInResult.columns[columnName].type === "serial") continue; indexesCount += 1;