drizzle-team / drizzle-team/drizzle-orm
[BUG]: Cached Postgres timestamp returns Invalid Date
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### Report hasn't been filed before.
- [x] I have verified that the bug I'm about to report hasn't been filed before.
### What version of `drizzle-orm` are you using?
0.45.1
### What version of `drizzle-kit` are you using?
^0.31.8
### Other packages
_No response_
### Describe the Bug
Caching something with a timestamp returns an Invalid Date
Schema
```ts
export const project = pgTable(
"project",
{
id: uuid("id").primaryKey().defaultRandom(),
name: varchar("name", { length: PROJECT_NAME_MAX_LENGTH }).notNull(),
token: text("token")
.notNull()
.unique()
.default(sql`MD5(RANDOM()::text)::text`),
slug: text("slug").notNull().unique(),
private: boolean("private").notNull().default(true),
templateId: text("template_id"),
createdAt: timestamp("created_at").defaultNow().notNull(),
ownerId: text("owner_id").notNull(),
},
(table) => [index("owner_id_index").on(table.ownerId)],
);
```
Code
```ts
const projects = await db
.select()
.from(project)
.where(eq(project.ownerId, ownerId))
.$withCache();
console.table(getProjects[0]);
```
Output
| Column | Values |
|--------|--------|
| id | some-id |
| name | some-name |
| token | some-token |
| slug | some-slug |
| private | true |
| templateId | some-template |
| createdAt | Invalid Date |
| ownerId | some id |
Tested with the Upstash Driver and https://github.com/LuggaPugga/bun-drizzle-cache
Contributor guide
Assessment
This issue has not been assessed yet.