drizzle-team / drizzle-team/drizzle-orm
[BUG]: pgSchema enum names starting with native type prefixes lose schema qualifier in generated SQL
- 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.45.2
### What version of `drizzle-kit` are you using?
0.31.10
### Other packages
_No response_
### Describe the Bug
Reproduction code
```ts
import { pgSchema } from "drizzle-orm/pg-core";
export const mySchema = pgSchema("myschema");
export const charType = mySchema.enum("char_type", ["x", "y"]);
export const items = mySchema.table("items", {
kind: charType("kind").notNull(),
});
```
then run `drizzle-kit generate`, the generated migration is as follows
```sql
CREATE TYPE "myschema"."char_type" AS ENUM('x', 'y');
CREATE TABLE "myschema"."items" (
"kind" char_type NOT NULL -- missing "myschema".
);
```
The problem is that my enum is called `char_type` and the code checks the native types for a prefix, not the full type, so `char_type` matches the native `char` and it doesn't get included.
https://github.com/drizzle-team/drizzle-orm/blob/273c78071d4841b497f5144734b38294df7ec64b/drizzle-kit/src/sqlgenerator.ts#L146
Contributor guide
Assessment
This issue has not been assessed yet.