drizzle-team / drizzle-team/drizzle-orm
[BUG]: drizzle-kit pull rewrites "character" inside public enum type names to "char"
- 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?
1.0.0-rc.3
### What version of `drizzle-kit` are you using?
1.0.0-rc.3
### Other packages
_No response_
### Describe the Bug
If an enum's name contains the word `character`, `pull` generates the wrong type
name for any column that uses it. The column references `char...` instead of the
real enum, both in `schema.ts` (undefined identifier) and in the generated
migration (type does not exist). The `pgEnum(...)` definition and the `CREATE TYPE`
are correct, only the reference is wrong.
Example: `characteristics_type` -> `charistics_type`, `character_role` -> `char_role`.
Enum names that only start with a native type (`char_type`, `text_type`, `varchar_status`...)
are fine, so this isn't the prefix detection from #5609 / #5628 (that PR doesn't
touch the name). Related but not a duplicate.
Cause looks like the alias normalization being applied after the enum name is
already resolved (`bin.cjs` ~226273):
```js
let columnTypeMapped = enumType ? enumType.name : column.type.replaceAll("[]", "");
columnTypeMapped = columnTypeMapped
.replace("character varying", "varchar")
.replace(" without time zone", "")
.replace("character", "char")
```
When enumType is set, enumType.name still goes through .replace("character", "char").
Repro:
CREATE TYPE characteristics_type AS ENUM ('a', 'b');
CREATE TABLE t (id serial primary key, kind characteristics_type NOT NULL);
pull produces kind: charistics_type() and "kind" "charistics_type", expected
characteristics_type.
Checked with the help of AI but manually validated. If you confirm it, I'm happy to open a PR for the fix :)
Contributor guide
Research direction
Start with the alias-normalization code in bin.cjs around line 226273 and reproduce the issue using the characteristics_type enum and table definition from the report. Run drizzle-kit pull, then verify that schema.ts and the generated migration preserve the enum name in the column reference while native type aliases remain normalized.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, typescript
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100