Skip to content

[Bug] Zod breaking error: Two enums one model #632

@amcmillion

Description

@amcmillion

Description and expected behavior
Using an enum in two separate fields of a model breaks Zod generation:

⠙ Running plugin ZodError compiling generated code:
node_modules/.zenstack/zod/models/TwoEnumsOneModelTest.schema.ts:4:10 - error TS2300: Duplicate identifier 'InventoryUnitSchema'.

4 import { InventoryUnitSchema } from '../enums/InventoryUnit.schema';
           ~~~~~~~~~~~~~~~~~~~
node_modules/.zenstack/zod/models/TwoEnumsOneModelTest.schema.ts:5:10 - error TS2300: Duplicate identifier 'InventoryUnitSchema'.

5 import { InventoryUnitSchema } from '../enums/InventoryUnit.schema';
           ~~~~~~~~~~~~~~~~~~~

✖ Running plugin Zod
: Error compiling generated code

Environment (please complete the following information):

  • ZenStack version: 1.0.0-beta.18
  • Prisma version: 5.1.1
  • Database type: Postgresql

Test setup

enum InventoryUnit {
  DIGITAL // no limit but we can still track sales
  FL_OZ
  GRAMS
  MILLILITERS
  OUNCES
  UNIT
  UNLIMITED
}

model TwoEnumsOneModelTest {
  id String @id @default(cuid())

  inventoryUnit   InventoryUnit @default(UNIT)
  inputUnit       InventoryUnit @default(UNIT)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions