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-kit generate succeeds but generates invalid SQL for default([]) - Postgres #2432

Closed
raymondji opened this issue Jun 4, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@raymondji
Copy link

raymondji commented Jun 4, 2024

What version of drizzle-orm are you using?

0.30.10

What version of drizzle-kit are you using?

0.21.4

Describe the Bug

https://orm.drizzle.team/learn/guides/empty-array-default-value explains the right way to do this, but as someone new to Drizzle it was confusing that drizzle-kit generate accepts default([]) but ends up generating invalid SQL.

Schema before:

  field: varchar("col", { length: 128 }).array(),

Schema after:

  field: varchar("col", { length: 64 }).array().notNull().default([]),

Run drizzle-kit generate - succeeds.

Got SQL in migration file:

ALTER TABLE "table" ALTER COLUMN "col" SET DEFAULT ;--> statement-breakpoint

Run drizzle-kit migrate - postgres invalid syntax error.

Expected behavior

Expected SQL in migration file:

ALTER TABLE "table" ALTER COLUMN "col" SET DEFAULT ARRAY[]::varchar(64)[];--> statement-breakpoint

OR it would be nice if drizzle-kit generate could return an error saying the schema is invalid, instead of succeeding. The type inference for default says it accepts a string[] | SQL<unknown> , so passing [] seems intuitive.

image

Environment & setup

Inside a devcontainer running the mcr.microsoft.com/devcontainers/javascript-node:1-22-bookworm Docker image

@AndriiSherman
Copy link
Member

Should be fixed in drizzle-kit0.24.0
Please check release notes before updating

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

2 participants