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]: drizzle-zod doesn't parse mysqlEnum as z.ZodEnum #3754

Closed
1 task done
ryuudotgg opened this issue Dec 11, 2024 · 6 comments
Closed
1 task done

[BUG]: drizzle-zod doesn't parse mysqlEnum as z.ZodEnum #3754

ryuudotgg opened this issue Dec 11, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@ryuudotgg
Copy link

ryuudotgg commented Dec 11, 2024

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.38.0

What version of drizzle-kit are you using?

0.30.0

Other packages

[email protected]

Describe the Bug

export const table = mysqlTable(
  "table",
  { enum: mysqlEnum("enum", ["One", "Two"]).notNull() },
);

export const schema = createInsertSchema(table);

The enum here should return a z.ZodEnum instead of a z.ZodString.

It looks like just a TypeScript issue, it's done during runtime: column.ts#L57

It used to work in [email protected]

@ryuudotgg ryuudotgg added the bug Something isn't working label Dec 11, 2024
@L-Mario564
Copy link
Collaborator

May I know the content of your tsconfig.json file? mysqlEnum returns z.ZodEnum in Drizzle's test suite, and I'm unable to reproduce this at the moment.

@ryuudotgg
Copy link
Author

@L-Mario564, I rolled back to 0.5.1 for now, here's my tsconfig:

{
  "$schema": "https://json.schemastore.org/tsconfig",
  "extends": "./base.json",
  "compilerOptions": {
    "declaration": true,
    "declarationMap": true,
    "emitDeclarationOnly": true,
    "noEmit": false,
    "outDir": "${configDir}/dist"
  }
}
{
  "$schema": "https://json.schemastore.org/tsconfig",
  "compilerOptions": {
    "esModuleInterop": true,
    "skipLibCheck": true,
    "target": "ESNext",
    "lib": ["ESNext"],
    "allowJs": true,
    "resolveJsonModule": true,
    "moduleDetection": "force",
    "isolatedModules": true,

    "incremental": true,
    "disableSourceOfProjectReferenceRedirect": true,
    "tsBuildInfoFile": "${configDir}/.cache/tsbuildinfo.json",

    "strict": true,
    "noUncheckedIndexedAccess": true,
    "checkJs": true,

    "module": "Preserve",
    "moduleResolution": "Bundler",
    "noEmit": true
  },
  "exclude": ["node_modules", "build", "dist", ".next"]
}

@pedrocarlo
Copy link

The same happens to me with pgEnum and text({enum:}) and varchar({enum:}). Drizzle zod translates it as an array of strings

@L-Mario564
Copy link
Collaborator

@nemanjastanic Is the sample code you provided is all that is required to reproduce the bug? I'm still completely unable to reproduce this.

@ryuudotgg
Copy link
Author

Hey @L-Mario564, I just retried this, it seems it's caused by #3732. I missed this previously because I managed to suppress the error by adding .partial({}).

Please feel free to close this issue if you want to consider it a duplicate!

@L-Mario564
Copy link
Collaborator

@nemanjastanic Will close this in favor of the one you mentioned. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants