Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Duplicate schema names exported #205

Open
brianbolnick opened this issue Nov 10, 2023 · 5 comments
Open

[BUG] Duplicate schema names exported #205

brianbolnick opened this issue Nov 10, 2023 · 5 comments
Assignees
Labels
bug (unconfirmed) Could be a bug

Comments

@brianbolnick
Copy link

Describe the bug
Hi! Love the concept behind this repo. Just ran my first generate and it has a duplicate schema exported. I've tried with both single and multi-file outputs. The multi-file has seemed to shed some possible light. Wondering if it has anything to do with a double export 🤷:

export const OutcomeUpdateArgsSchema: z.ZodType<Prisma.OutcomeUpdateArgs> = z.object({
  select: OutcomeSelectSchema.optional(),
  include: OutcomeIncludeSchema.optional(),
  data: z.union([ OutcomeUpdateInputSchema,OutcomeUncheckedUpdateInputSchema ]),
  where: OutcomeWhereUniqueInputSchema,
}).strict() ;

export default OutcomeUpdateArgsSchema;

Which leads to the index file including both of these:

export { OutcomeUpdateArgsSchema } from './OutcomeUpdateArgsSchema';
export { OutcomeUpdateArgsSchema } from './OutcomeUpdateArgsSchema';

It only happened with this one model, so it very likely could be an issue on our end. Here's the schema itself:


model OutcomeUpdate {
  id      String @id @default(cuid())
  changes Json

  faculty   Faculty? @relation(fields: [facultyId], references: [id])
  facultyId String?
  outcome   Outcome  @relation(fields: [outcomeId], references: [id], onDelete: Cascade, onUpdate: Cascade)
  outcomeId String
  student   Student? @relation(fields: [studentId], references: [id])
  studentId String?

  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
}

Screenshots
N/A

Package versions (please complete the following information):

  • zod: 3.21.4
  • prisma: 4.16.2
  • zod-prisma-types 3.1.1

Additional context
N/A

@chrishoermann
Copy link
Owner

@brianbolnick thanks for repoting the issue, can you please provide a complete schema if possible so i can run it on my end?

@chrishoermann
Copy link
Owner

@brianbolnick I changed the generation of imports in barrel files to use Set instead of array to prevent duplicate imports. Can you please check if this solves your problem or if it generates problems in other places of the schemas.

Please also be aware that the latest version is targeted for the use with prisma 5.2.x so maybe a this bug could be a result of this version discrepancy.

Also zod 3.21.4 might make problems because of a type error in the schemas that happens in zod > 3.21.1 - a flag to use type assertion - useTypeAssertions = true in generator config - is implemented that can circumvent this bug but that also overrides the type system, so please use at your own risk

@brianbolnick
Copy link
Author

Looks like it is still occurring with the current versions of prisma and zod, unfortunately. I'll try to revert back where possible, but may need to figure something else out until it's all fully supported :)

@chrishoermann
Copy link
Owner

Well, that's odd. Is it possible to provide the full schema so I can reproduce the issue on my end?

@brianbolnick
Copy link
Author

Unfortunately it's a private repo and I can't share it :/ It's only affecting one model, so I'll see if I can put together a replica of it and any relations to it that you could use later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug (unconfirmed) Could be a bug
Projects
None yet
Development

No branches or pull requests

2 participants