Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE]: Add text(..., { mode: "timestamp" }) support to SQLite #3154

Open
WesSouza opened this issue Oct 18, 2024 · 0 comments
Open

[FEATURE]: Add text(..., { mode: "timestamp" }) support to SQLite #3154

WesSouza opened this issue Oct 18, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@WesSouza
Copy link

WesSouza commented Oct 18, 2024

Describe what you want

Currently, SQLite allows default values for a text column to be set as CURRENT_TIMESTAMP. Drizzle however only automatically casts integer(..., { mode: 'timestamp' } (and _ms) to Date objects, making those two features incompatible.

We should allow text to also be a timestamp so it can be used in conjunction with the default value:

export const log = sqliteTable("log", {
  id: integer("id").primaryKey(),
  // ...
  created:
    text("created", { mode: "timestamp" })
      .default(sql`(CURRENT_TIMESTAMP)`),
});

Expecting created to be of type Date when selecting.

Why?

Currently it isn't possible to achieve the "default to current timestamp" when columns are of type integer, only text.

@WesSouza WesSouza added the enhancement New feature or request label Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant