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
24.56k stars 646 forks source link

[BUG]: Studio + mysql default mode, wrong format related timezone #2747

Closed yanghoxom closed 2 weeks ago

yanghoxom commented 3 months ago

What version of drizzle-orm are you using?

0.31.2

What version of drizzle-kit are you using?

0.22.8

Describe the Bug

When I

  1. Add a new record in the studio https://local.drizzle.studio/
  2. or insert data in mysql cli by sql raw

createdAt will return the correct time but wrong format my local time is: 2024-08-04 09:42:20.000 data in the studio: 2024-08-04T02:42:20.000Z data that I get in backend: 2024-08-04T09:42:20.000Z data that I get in MySQL: 2024-08-04 09:42:20

my schema

createdAt: timestamp('created_at', { mode: 'date' }).defaultNow().notNull(),

as i understand, mysql is displaying data according to system timezone studio/backend misunderstands timezone or does not have timezone config which makes it "think" data is utc and display data in utc format

update If I set env is TZ=UTC studio will show: 2024-08-04T09:42:20.000Z backend still show: 2024-08-04T09:42:20.000Z -> still wrong

Expected behavior

orm should show get data with the correct format/time

Environment & setup

No response

yanghoxom commented 3 months ago

my solution is set database timezone to utc ref: https://discord.com/channels/1043890932593987624/1084576896039260202/threads/1270642238661197824

AndriiSherman commented 2 weeks ago

should be fixed by upgrading to drizzle-orm@0.36.0 and drizzle-kit@0.27.0