drizzle-cursor
drizzle-cursor copied to clipboard
Does not work with date columns
const cursorConfig: CursorConfig = {
cursors: [{ order: 'DESC', key: 'createdAt', schema: schema.users.createdAt }],
primaryCursor: { order: 'DESC', key: 'id', schema: schema.users.id },
};
const cursor = generateCursor(cursorConfig);
When then passing it to db.queries.users.findMany
results in:
value.toISOString is not a function. (In 'value.toISOString()', 'value.toISOString' is undefined)
Got the same issue
Hi @erickreutz @croshim do you have a reproducible example? I added some tests and SQL generated query works fine, I guess could be due to null
record that drizzle's eq
, gt
or lt
functions not handle.
Hi,
I was able to find a workaround for this error by changing the schema definition from:
createdAt: timestamp('created_at').notNull().defaultNow(),
to
createdAt: timestamp('created_at', { mode: 'string' }).notNull().defaultNow(),
yes,same problem. this fixed.
createdAt: customTimestamp('createdAt', {
withTimezone: true,
precision: 3,
})
.notNull().default(sql`now()`),
I want my date column to be nullable
Experiencing the same error. Tried with both drizzle v0.29.5 and v0.30.10. Same "value.toISOString" message.
I have the same issue.
Making this change solved, but it doesn't feel great.
createdAt: timestamp('created_at').notNull().defaultNow(),
to
createdAt: timestamp('created_at', { mode: 'string' }).notNull().defaultNow(),
Could someone provide a reproducible minimal example? I've been trying to figure it out the error on
- https://github.com/xantiagoma/drizzle-cursor/blob/main/test/extended/dates.pg.test.ts
- https://github.com/xantiagoma/drizzle-cursor/blob/main/test/extended/dates.mysql.test.ts but not luck yet.