drizzle-team / drizzle-team/drizzle-orm

[BUG]: Milliseconds incorrectly truncated on timestamps for planetscale adapter

Open
#624 2 comments 2 reactions 1 assignee Claimed by @Angelelz View on GitHub
bug db/mysql driver/planetscale priority qb/crud
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### What version of `drizzle-orm` are you using?

0.26.0

### What version of `drizzle-kit` are you using?

0.18.0

### Describe the Bug

Create a mysql table with a timestamp field with `fsp: 6` and `mode: "date"`

```
export const user = mysqlTable(
"user",
{
id: char("id", {length: 26}).primaryKey(),
consentedAt: timestamp("consented_at", { mode: "date", fsp: 6 });
},
);
```

Insert a date into the table:
```
await db.insert(userTable).values({
id,
consentedAt: new Date(),
});
```

The Date that I pass in is serialized to a date string with the milliseconds missing. When I print to the SQL to the console, I see this:
```
{
sql: 'update `user` set `consented_at` = ?',
params: ['2023-05-23 19:15:16']
}
```

### Expected behavior

I expected the SQL statement to be:
```
{
sql: 'update `user` set `consented_at` = ?',
params: ['2023-05-23 19:15:16.1234']
}
```

I'd prefer to use TIMESTAMP(6) or NOW(6) but I can't because of this bug: https://github.com/drizzle-team/drizzle-orm/issues/472

But now that I've found this bug, where I can't set the milliseconds through the mysql adapter at all, I'm truly stuck.

### Environment & setup

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.