Skip to content

Commit 97a03d4

Browse files
ymc9Copilot
andauthored
fix(orm): correcting timezone for Date returned in nested queries (#450)
* fix(orm): correcting timezone for Date returned in nested queries * Update packages/orm/src/client/crud/dialects/postgresql.ts Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
1 parent a9ff7e4 commit 97a03d4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/orm/src/client/crud/dialects/postgresql.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ export class PostgresCrudDialect<Schema extends SchemaDef> extends BaseCrudDiale
106106

107107
private transformOutputDate(value: unknown) {
108108
if (typeof value === 'string') {
109-
return new Date(value);
109+
// PostgreSQL's jsonb_build_object serializes timestamptz as ISO 8601 strings
110+
// in UTC but without the 'Z' suffix (e.g., "2023-01-01T12:00:00.123456").
111+
// We add 'Z' to explicitly mark them as UTC for correct Date object creation.
112+
return new Date(value.endsWith('Z') ? value : `${value}Z`);
110113
} else if (value instanceof Date && this.options.fixPostgresTimezone !== false) {
111114
// SPECIAL NOTES:
112115
// node-pg has a terrible quirk that it returns the date value in local timezone

0 commit comments

Comments
 (0)