Description
Report hasn't been filed before.
- 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.42.0
What version of drizzle-kit
are you using?
0.31.0
Other packages
No response
Describe the Bug
[BUG] Breaking change in v0.42.0: PgSchema enum type definition causing NestJS/TypeScript errors
Describe the Bug
Undesired Behavior
After upgrading to drizzle-orm v0.42.0, the type definition for PgSchema.enum
has changed from typeof pgEnum
to any
in pg-core/schema.d.ts
. This breaks strict TypeScript type checking due to use of any.
We use drizzle-kit introspect
to generate our schema file from our existing PostgreSQL database.
Steps to Reproduce for our use-case
- Have a NestJS application using PostgreSQL with Drizzle ORM
- Use
drizzle-kit introspect
to generate schema from a database with enums:
// Generated schema.ts
export const priorityLevel = mySchema.enum("priority_level", [
'critical',
'high',
'medium',
'low',
'trivial'
]);
- Use these generated enums in NestJS entities:
@ApiProperty({
description: 'Task priority level',
enum: priorityLevel.enumValues,
nullable: true,
})
public priority!: string | null;
- Upgrade from v0.41.0 to v0.42.0
- TypeScript compilation fails due to enum type issues
- Running
drizzle-kit introspect
again doesn't help as it still generates string arrays for enums
Desired Result
The enum type definition should maintain proper typing while supporting both TypeScript enums and string unions, rather than using any
. This would preserve type safety while allowing the new enum functionality introduced in v0.42.0, regardless of whether the enums are manually defined or generated via introspection.
Additional Information
- Database: PostgreSQL
- TypeScript version: 5.7.3
- NestJS version: 11.0.0
- Node.js version: 22.13.1
Relevant Code
Previous type definition (pre-v0.42.0):
export declare class PgSchema<TName extends string = string> implements SQLWrapper {
enum: typeof pgEnum;
}
Current type definition (v0.42.0):
export declare class PgSchema<TName extends string = string> implements SQLWrapper {
enum: any;
}
Workaround
Currently rolling back to the previous version of drizzle-orm.