Capital letter causes index error when running npx drizzle-kit push

if i have a users table
export const users = pgTable(
"Users",
{
id: bigint("ID", { mode: "number" })
.primaryKey()
.generatedAlwaysAsIdentity(),
email: varchar("email", { length: 255 }).unique(),
(table) => [
uniqueIndex("emailUniqueIndex").on(lower(table.email)),
]
);
export const users = pgTable(
"Users",
{
id: bigint("ID", { mode: "number" })
.primaryKey()
.generatedAlwaysAsIdentity(),
email: varchar("email", { length: 255 }).unique(),
(table) => [
uniqueIndex("emailUniqueIndex").on(lower(table.email)),
]
);
with this function from the docs
export function lower(column: AnyPgColumn): SQL {
return sql`lower(${column})`;
}
export function lower(column: AnyPgColumn): SQL {
return sql`lower(${column})`;
}
i get the error when running npx drizzle-kit push
error: malformed array literal: "{lower(("Email")::text)}"
at /code/node_modules/pg-pool/index.js:45:11
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async Object.query (/code/node_modules/drizzle-kit/bin.cjs:78762:26)
at async /code/node_modules/drizzle-kit/bin.cjs:37705:31 {
length: 149,
severity: 'ERROR',
code: '22P02',
detail: 'Incorrectly quoted array element.',
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'arrayfuncs.c',
line: '902',
routine: 'ReadArrayToken'
}

Node.js v22.12.0
error: malformed array literal: "{lower(("Email")::text)}"
at /code/node_modules/pg-pool/index.js:45:11
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async Object.query (/code/node_modules/drizzle-kit/bin.cjs:78762:26)
at async /code/node_modules/drizzle-kit/bin.cjs:37705:31 {
length: 149,
severity: 'ERROR',
code: '22P02',
detail: 'Incorrectly quoted array element.',
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'arrayfuncs.c',
line: '902',
routine: 'ReadArrayToken'
}

Node.js v22.12.0
if i change the email field from ("Email" to "email")
email: varchar("Email", { length: 255 }).unique(),
email: varchar("Email", { length: 255 }).unique(),
to
email: varchar("email", { length: 255 }).unique(),
email: varchar("email", { length: 255 }).unique(),
there are no problems at all
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?