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.67k stars 650 forks source link

[BUG]: Date retrieved from Mysql differs from date stored in Mysql #3049

Open bohumilmilacek opened 1 month ago

bohumilmilacek commented 1 month ago

What version of drizzle-orm are you using?

0.33.0

What version of drizzle-kit are you using?

0.24.2

Describe the Bug

My timezone is Europe/Prague, I set it in both the database and in the drizzle connection however those hours differ, drizzle retrieves the dates and sets them + 2 hours

const connection = mysql.createPool({
  uri,
  timezone: 'Europe/Prague',
});
  db:
    container_name: my_db
    image: mysql:latest
    restart: unless-stopped
    environment:
      MYSQL_DATABASE: my_db
      MYSQL_ROOT_PASSWORD: xxxxx
      TZ: Europe/Prague
    ports:
      - "9106:3306"
    volumes:
      - ....

Example of dates retrieved from db:

STORED IN DB: '10/4/2024, 8:08:56 PM', '10/5/2024, 1:00:00 AM', '10/4/2024, 6:11:12 PM', '10/5/2024, 1:00:00 AM', '10/4/2024, 5:54:18 PM'

DRIZZLE STATES: '10/4/2024, 10:08:56 PM', '10/5/2024, 3:00:00 AM', '10/4/2024, 8:11:12 PM', '10/5/2024, 3:00:00 AM', '10/4/2024, 7:54:18 PM'

Please help me with this issue. Is drizzle converting the dates not using the timezone or is it using some time format which messes it up?

Expected behavior

Expected behaviours is for the drizzle to retrieve same dates as are in the database.

STORED IN DB: '10/4/2024, 8:08:56 PM', '10/5/2024, 1:00:00 AM', '10/4/2024, 6:11:12 PM', '10/5/2024, 1:00:00 AM', '10/4/2024, 5:54:18 PM'

DRIZZLE STATES: '10/4/2024, 8:08:56 PM', '10/5/2024, 1:00:00 AM', '10/4/2024, 6:11:12 PM', '10/5/2024, 1:00:00 AM', '10/4/2024, 5:54:18 PM'

Environment & setup

DvShu commented 1 month ago

The same problem!

The result of my query using the framework is:

1729504169528

The result of my query using mysql2 is:

1729504202000