You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Connect to the PostgreSQL database, after connection, execute SET TIME ZONE 'UTC';
constconnectionString=process.env.DATABASE_URL||"";constclient=postgres(connectionString);constdrizzle=drizzle(client);awaitdrizzle.execute(sql`SET TIME ZONE 'UTC';`);
At this point, executing SHOW TIMEZONE shows 'UTC'
3. Insert a date to the timestamp column as ISO string. For example:
awaitdrizzle.insert(user).values({registered_at: '2023-11-30T18:30:04.823Z'})// ISO
At this point, getting table data via pgAdmin returns a valid date: '2023-11-30T18:30:04.823Z' (in UTC, not converted to any timezone because SET TIME ZONE 'UTC' was executed). However, drizzle returns '2023-11-30T15:30:04.823Z' (-3 hours). My timezone is +3.
Expected behavior
when setting TimeZone to UTC in PostgreSQL, drizzle respects this setting and does not convert timestamp, but saves and retrieves it as-is (in UTC)
Environment & setup
database: PostgreSQL
The text was updated successfully, but these errors were encountered:
I tried to create a custom type similar to this: #833, but it didn't worked.
The workaround is to use mode='date' instead of mode='string'. I would prefer to use string but OK.
The problem with this workaround is that i'm using introspection to generate drizzle schema from database, and it automatically sets timestamp to mode="string". To fix this, after running drizzle introspect command, I run the script that changes timestampmode="string" to mode="date".
Should be fixed in drizzle-orm@beta. I would appreciate some feedback to confirm whether this issue has been resolved in this tag.
I plan to release it in version 0.30.0 tomorrow or within the next few days; I simply aim to address this substantial set of issues we're encountering. I'll be duplicating this message across all similar issues we're facing.
What version of
drizzle-orm
are you using?0.28.6
What version of
drizzle-kit
are you using?0.19.13
Describe the Bug
timestamp
column,mode="string"
. For example:SET TIME ZONE 'UTC';
At this point, executing
SHOW TIMEZONE
shows 'UTC'3. Insert a date to the
timestamp
column as ISO string. For example:At this point, getting table data via pgAdmin returns a valid date: '2023-11-30T18:30:04.823Z' (in UTC, not converted to any timezone because
SET TIME ZONE 'UTC'
was executed). However, drizzle returns '2023-11-30T15:30:04.823Z' (-3 hours). My timezone is +3.Expected behavior
when setting TimeZone to UTC in PostgreSQL, drizzle respects this setting and does not convert timestamp, but saves and retrieves it as-is (in UTC)
Environment & setup
database: PostgreSQL
The text was updated successfully, but these errors were encountered: