.array() can't automatically type cast

export const recurrencePattern = createTable(
"recurrence_pattern",
{
id: serial().primaryKey(),
type: varchar({ length: 50 }).notNull(),
daysOfWeek: integer().array().default(sql`'{}'::integer[]`),
endsAt: timestamp({ withTimezone: true }),
createdAt: timestamp({ withTimezone: true })
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
}
);
export const recurrencePattern = createTable(
"recurrence_pattern",
{
id: serial().primaryKey(),
type: varchar({ length: 50 }).notNull(),
daysOfWeek: integer().array().default(sql`'{}'::integer[]`),
endsAt: timestamp({ withTimezone: true }),
createdAt: timestamp({ withTimezone: true })
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
}
);
PostgresError: column "daysOfWeek" cannot be cast automatically to type integer[]
at ErrorResponse (file:///Users/shawn/dev/rally/node_modules/postgres/src/connection.js:788:26)
at handle (file:///Users/shawn/dev/rally/node_modules/postgres/src/connection.js:474:6)
at TLSSocket.data (file:///Users/shawn/dev/rally/node_modules/postgres/src/connection.js:315:9)
at TLSSocket.emit (node:events:519:28)
at addChunk (node:internal/streams/readable:559:12)
at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
at Readable.push (node:internal/streams/readable:390:5)
at TLSWrap.onStreamRead (node:internal/stream_base_commons:191:23)
at TLSWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
severity_local: 'ERROR',
severity: 'ERROR',
code: '42804',
hint: 'You might need to specify "USING "daysOfWeek"::integer[]".',
file: 'tablecmds.c',
line: '12391',
routine: 'ATPrepAlterColumnType'
}
PostgresError: column "daysOfWeek" cannot be cast automatically to type integer[]
at ErrorResponse (file:///Users/shawn/dev/rally/node_modules/postgres/src/connection.js:788:26)
at handle (file:///Users/shawn/dev/rally/node_modules/postgres/src/connection.js:474:6)
at TLSSocket.data (file:///Users/shawn/dev/rally/node_modules/postgres/src/connection.js:315:9)
at TLSSocket.emit (node:events:519:28)
at addChunk (node:internal/streams/readable:559:12)
at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
at Readable.push (node:internal/streams/readable:390:5)
at TLSWrap.onStreamRead (node:internal/stream_base_commons:191:23)
at TLSWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
severity_local: 'ERROR',
severity: 'ERROR',
code: '42804',
hint: 'You might need to specify "USING "daysOfWeek"::integer[]".',
file: 'tablecmds.c',
line: '12391',
routine: 'ATPrepAlterColumnType'
}
2 Replies
TOSL
TOSLOP2mo ago
Anyone know what I'm doing wrong? It looks right to me when comparing to docs example.
TOSL
TOSLOP2mo ago
Drizzle ORM - Empty array as a default value
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Want results from more Discord servers?
Add your server