drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅
https://orm.drizzle.team
Apache License 2.0
23.53k stars 577 forks source link

[BUG]: #2182

Closed christianstamati closed 1 month ago

christianstamati commented 5 months ago

What version of drizzle-orm are you using?

0.30.8

What version of drizzle-kit are you using?

0.20.16

Describe the Bug

When I create this entity from drizzle studio "Add record" button

import { text, sqliteTable } from "drizzle-orm/sqlite-core";
import { sql } from "drizzle-orm";

export const user = sqliteTable("user", {
  id: text("id").notNull().primaryKey(),
  name: text("name").notNull(),
  email: text("email").notNull(),
  createdAt: text("created_at")
    .default(sql`CURRENT_TIMESTAMP`)
    .notNull(),
});

The created_at is not being populated with the actual date but i see "CURRENT_TIMESTAMP"

image

If i run the following in SQL runner:

INSERT INTO
  user (id, name, email)
VALUES
  ('123456789', 'John Doe', 'john@example.com');

the entity is created with the correct date.

Note: note riproducible with version: ^0.20.14

Expected behavior

When I add a record from Studio I need to see the current time of creation if i leave the field as DEFAULT.

Environment & setup

I am using Drizzle and Turso in next JS environment.

RomanNabukhotnyi commented 1 month ago

@christianstamati Hey! This should be fixed, try it.