-
-
Notifications
You must be signed in to change notification settings - Fork 126
Closed
Description
Description and expected behavior
Schema:
enum FooType {
Bar
Baz
}
// Add JSON type field so a logical prisma client is generated.
// Polymorphic models also trigger this bug
type Meta {
test String?
}
model Foo {
id String @id @db.Uuid @default(uuid())
type FooType
meta Meta @json
@@validate(type == Bar, "FooType must be Bar")
}
Screenshots
The generated Zod Schema file for Foo then contains an invalid import. .zenstack/models is a .d.ts file and contains no value exports.
Environment (please complete the following information):
- ZenStack version: 2.13.0
- Prisma version: 6.5.0
- Database type: Postgresql
Additional context
This bug doesn't occur when a logical client isn't generated. I believe the issue lies somewhere in this code, It doesn't really make sense to me that prismaClientPath is being mapped to a definitions file?
zenstack/packages/schema/src/plugins/enhancer/index.ts
Lines 29 to 45 in 8a62f63
| const { dmmf, newPrismaClientDtsPath } = await new EnhancerGenerator(model, options, project, outDir).generate(); | |
| let prismaClientPath: string | undefined; | |
| if (dmmf) { | |
| // a logical client is generated | |
| if (options.output || globalOptions?.output) { | |
| // handle custom output path | |
| // get the absolute path of the prisma client types | |
| const prismaClientPathAbs = path.resolve(outDir, 'models'); | |
| // resolve it relative to the schema path | |
| prismaClientPath = normalizedRelative(path.dirname(options.schemaPath), prismaClientPathAbs); | |
| } else { | |
| prismaClientPath = `${RUNTIME_PACKAGE}/models`; | |
| } | |
| } |
Metadata
Metadata
Assignees
Labels
No labels
