Skip to content

[BUG]: Documentation Error: Sqlite timestamp_ms "unixepoch() * 1000" is wrong #2810

@pburrows

Description

@pburrows

What version of drizzle-orm are you using?

0.33.0

What version of drizzle-kit are you using?

0.24.0

Describe the Bug

On this page, the documentation to store timestamps in sqlite with millisecond precision uses this as the example:

timestamp2: integer('timestamp2', { mode: 'timestamp_ms' })
    .notNull()
    .default(sql`(unixepoch() * 1000)`),

But this just stores the timestamp at second precision and adds 3 zeroes to the end. In order to get the timestamp to store at subsecond precision, you must change the default value to this:

timestamp2: integer('timestamp2', { mode: 'timestamp_ms' })
    .notNull()
    .default(sql`(unixepoch('subsecond') * 1000)`),

This isn't a serious bug, just an issue with the documentation.

Expected behavior

Simple documentation update.

Environment & setup

drizzle orm website.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsImprovements or additions to documentationdocs/incorrect

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions