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

Error: column "XYZ" cannot be cast automatically to type enum_x_y_z #8891

Closed
tilman opened this issue Oct 28, 2024 · 2 comments
Closed

Error: column "XYZ" cannot be cast automatically to type enum_x_y_z #8891

tilman opened this issue Oct 28, 2024 · 2 comments

Comments

@tilman
Copy link

tilman commented Oct 28, 2024

Describe the Bug

If I change the options of a select field I will get the error Error: column "XYZ" cannot be cast automatically to type enum_x_y_z.
Under the hood the error is caused by the following SQL command: ALTER TABLE xyz ALTER COLUMN x_y_z SET DATA TYPE enum_x_y_z;

The solution would be to run the SQL command with USING enum_xyz appended. This will enable automatic conversion using this new datatype. Therefore the query should be changed to ALTER TABLE xyz ALTER COLUMN x_y_z SET DATA TYPE enum_x_y_z USING xyz::enum_xyz;

Link to the code that reproduces this issue

N/A

Reproduction Steps

  1. Start a new payload project npx create-payload-app@beta -t blank
  2. create a field with type select
  3. add some content with the field
  4. change the options of the filed
  5. you will receive the cast error

Which area(s) are affected? (Select all that apply)

db-postgres, db-vercel-postgres

Environment Info

Binaries:
Node: 20.18.0
npm: 10.8.2
Yarn: 1.22.21
pnpm: 8.15.8
Relevant Packages:
payload: 3.0.0-beta.116
next: 15.0.0-canary.173
@payloadcms/db-postgres: 3.0.0-beta.116
@payloadcms/email-nodemailer: 3.0.0-beta.116
@payloadcms/graphql: 3.0.0-beta.116
@payloadcms/live-preview: 3.0.0-beta.116
@payloadcms/live-preview-react: 3.0.0-beta.116
@payloadcms/next/utilities: 3.0.0-beta.116
@payloadcms/plugin-cloud: 3.0.0-beta.116
@payloadcms/plugin-form-builder: 3.0.0-beta.116
@payloadcms/plugin-nested-docs: 3.0.0-beta.116
@payloadcms/plugin-redirects: 3.0.0-beta.116
@payloadcms/plugin-search: 3.0.0-beta.116
@payloadcms/plugin-seo: 3.0.0-beta.116
@payloadcms/richtext-lexical: 3.0.0-beta.116
@payloadcms/translations: 3.0.0-beta.116
@payloadcms/ui/shared: 3.0.0-beta.116
react: 19.0.0-rc-3edc000d-20240926
react-dom: 19.0.0-rc-3edc000d-20240926
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 22.6.0: Wed Jul 5 22:22:05 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6000
Available memory (MB): 32768
Available CPU cores: 10

@tilman tilman added status: needs-triage Possible bug which hasn't been reproduced yet v3 labels Oct 28, 2024
@jmikrut
Copy link
Member

jmikrut commented Oct 28, 2024

Hey @tilman

We wouldn't be able to control the output SQL statements from the Payload side - that's all handled by Drizzle.

I'd try and create a minimal reproducible demo for the Drizzle team and open an issue there.

@jmikrut jmikrut closed this as completed Oct 28, 2024
@github-actions github-actions bot removed the status: needs-triage Possible bug which hasn't been reproduced yet label Oct 28, 2024
Copy link
Contributor

This issue has been automatically locked.
Please open a new issue if this issue persists with any additional detail.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants