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]: Introspecting varchar[] type produces syntactically invalid schema.ts #1633

Closed
nguyenbry opened this issue Dec 11, 2023 · 1 comment
Closed
Assignees
Labels
bug Something isn't working drizzle/kit

Comments

@nguyenbry
Copy link

What version of drizzle-orm are you using?

0.29.1

What version of drizzle-kit are you using?

0.20.6

Describe the Bug

Using Supabase Postgres:

Create table

CREATE table IF NOT EXISTS
  "movements" (
    id serial PRIMARY KEY NOT NULL,
    name varchar(50) NOT NULL UNIQUE
  );

Modify table to add varchar[] field with default

ALTER TABLE "movements"
ALTER column tags SET DEFAULT '{}'

Run $ drizzle-kit introspect:pg

This produces a schema.ts file with:

export const movements = pgTable("movements", {
	id: serial("id").primaryKey().notNull(),
	name: varchar("name", { length: 50 }).notNull(),
	tags: varchar("tags", { length: 40)[ }).default('{}'::character varying[]).array().notNull(),
},
(table) => {
	return {
		movementsNameKey: unique("movements_name_key").on(table.name),
	}
});

Note the syntax errors near { length: 40 } and character varying.

Expected behavior

I believe the correct syntax is

tags: varchar("tags", { length: 40 }).default("{}").array().notNull(),

Environment & setup

I am using Supabase Postgres.

The issue happens in local development environment on Node 20.5.1

@AndriiSherman
Copy link
Member

This should be fixed in [email protected]
If you still encounter this issue, please reopen the ticket

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

Successfully merging a pull request may close this issue.

3 participants