Drizzle pg client throwing `scanner_yyerror` on push

Getting the following error upon running drizzle-kit push:pg to my local postgres. Drizzle-Kit version 0.20.17 Drizzle-ORM version 0.30.9 using pg version 8.11.3 Error:
error: syntax error at or near ","
at /Users/paulmikulskis/Development/Archive/product-eng/node_modules/drizzle-kit/bin.cjs:43518:21
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async PgPostgres.query (/Users/paulmikulskis/Development/Archive/product-eng/node_modules/drizzle-kit/bin.cjs:62584:21)
at async Command.<anonymous> (/Users/paulmikulskis/Development/Archive/product-eng/node_modules/drizzle-kit/bin.cjs:66268:9) {
length: 91,
severity: 'ERROR',
code: '42601',
detail: undefined,
hint: undefined,
position: '152',
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'scan.l',
line: '1241',
routine: 'scanner_yyerror'
}
error: syntax error at or near ","
at /Users/paulmikulskis/Development/Archive/product-eng/node_modules/drizzle-kit/bin.cjs:43518:21
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async PgPostgres.query (/Users/paulmikulskis/Development/Archive/product-eng/node_modules/drizzle-kit/bin.cjs:62584:21)
at async Command.<anonymous> (/Users/paulmikulskis/Development/Archive/product-eng/node_modules/drizzle-kit/bin.cjs:66268:9) {
length: 91,
severity: 'ERROR',
code: '42601',
detail: undefined,
hint: undefined,
position: '152',
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'scan.l',
line: '1241',
routine: 'scanner_yyerror'
}
(Also made sure there are no dashes (- )in any fields nor table names.) Looking at bin.js where the error is throwing, I can see t error is thrown when Drizzle-Kit attempts to issue a statement to the given connection's client.
I console.log this statement to view this statement right before the error is thrown:
issuing statement: CREATE TABLE IF NOT EXISTS "grant_meta" (
"id" uuid PRIMARY KEY NOT NULL,
"grant_type" varchar(256) NOT NULL,
"categories" grant_category[] DEFAULT ,
"subject_type" "media_grant_subject_type" DEFAULT 'TRACK' NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp DEFAULT now() NOT NULL
);
issuing statement: CREATE TABLE IF NOT EXISTS "grant_meta" (
"id" uuid PRIMARY KEY NOT NULL,
"grant_type" varchar(256) NOT NULL,
"categories" grant_category[] DEFAULT ,
"subject_type" "media_grant_subject_type" DEFAULT 'TRACK' NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp DEFAULT now() NOT NULL
);
...nothing unusual jumps out to me. Some CREATE statements do work! What is most strange is that when this runs, drizzle will recognize the metadata from the journal and ask about each of the tables that should be created or replaced. After running through the whole, set I can notice two of the many tables get created on Drizzle-Studio, while the rest remain uncreated and the console throws the error user g0053 shared. You can see my package for drizzle db stuff and schema here: https://github.com/paulmikulskis/product-eng/tree/main/packages/db Thank you very much for any help!
GitHub
product-eng/packages/db at main · paulmikulskis/product-eng
Contribute to paulmikulskis/product-eng development by creating an account on GitHub.
1 Reply
pineappaul
pineappaul2mo ago
UPDATE: This error will throw when trying to use array() with an enum. Here is the table definition:
export const grantMeta = pgTable("grant_meta", {
id: uuid("id").primaryKey(),
grantType: varchar("grant_type", { length: 256 }).notNull(),
categories: grantCategoryEnum("categories").array().default([]),
subjectType: mediaGrantSubjectTypeEnum("subject_type")
.notNull()
.default("TRACK"),
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at")
.defaultNow()
.notNull()
.$onUpdate(() => sql`NOW()`),
});
export const grantMeta = pgTable("grant_meta", {
id: uuid("id").primaryKey(),
grantType: varchar("grant_type", { length: 256 }).notNull(),
categories: grantCategoryEnum("categories").array().default([]),
subjectType: mediaGrantSubjectTypeEnum("subject_type")
.notNull()
.default("TRACK"),
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at")
.defaultNow()
.notNull()
.$onUpdate(() => sql`NOW()`),
});
When .array() is removed from categories and ins instead treated as a normal enum, the push works without error