drizzle-team / drizzle-team/drizzle-orm
[BUG]: Introspecting Functional indexes leads to error
- 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?
0.43.1
### What version of `drizzle-kit` are you using?
0.31.1
### Other packages
_No response_
### Describe the Bug
When im trying to run `drizzle-kit pull` I get this:
```
Pulling from ['steamsets'] list of schemas
[✓] 45 tables fetched
[✓] 296 columns fetched
[✓] 100 indexes fetched
[✓] 0 foreign keys fetched
[⣷] 0 policies fetching
[✓] 0 check constraints fetched
[✓] 0 views fetched
TypeError: Cannot read properties of null (reading 'camelCase')
at /Users/flo/Developer/steamsets/backend/schema/node_modules/drizzle-kit/bin.cjs:84136:39
at /Users/flo/Developer/steamsets/backend/schema/node_modules/drizzle-kit/bin.cjs:84657:62
at Array.map ()
at /Users/flo/Developer/steamsets/backend/schema/node_modules/drizzle-kit/bin.cjs:84657:40
at Array.forEach ()
at createTableUniques3 (/Users/flo/Developer/steamsets/backend/schema/node_modules/drizzle-kit/bin.cjs:84651:12)
at /Users/flo/Developer/steamsets/backend/schema/node_modules/drizzle-kit/bin.cjs:84265:24
at Array.map ()
at schemaToTypeScript3 (/Users/flo/Developer/steamsets/backend/schema/node_modules/drizzle-kit/bin.cjs:84228:61)
at introspectMysql (/Users/flo/Developer/steamsets/backend/schema/node_modules/drizzle-kit/bin.cjs:86316:18)
```
The schema that breaks it looks like the following:
```sql
CREATE TABLE `app_badge_tag` (
`tag_id` varchar(255) NOT NULL,
`badge_id` varchar(32) NOT NULL,
`design_id` varchar(255) DEFAULT NULL,
`color_id` varchar(255) DEFAULT NULL,
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`tag_id`),
UNIQUE KEY `app_badge_tag_pk` (`badge_id`,((case when (`design_id` is null) then _utf8mb4'' else `design_id` end)),((case when (`color_id` is null) then _utf8mb4'' else `color_id` end))),
KEY `app_badge_tag_design_id_index` (`design_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
```
Looking into the error, it's due to createTableUniques3 running through this unqs entry:
```
it: { name: 'app_badge_tag_pk', columns: [ 'badge_id', null, null ] }
```
Contributor guide
Assessment
This issue has not been assessed yet.