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
{{ message }}
Repository navigation
[BUG]: pg timestamp: a Date past the year 9999 is sent as "+010000-…", which PostgreSQL refuses (22009) #6552
A pg timestamp column sends a Date as value.toISOString() (PgTimestamp.mapToDriverValue, and PgTimestampString's, in pg-core/columns/timestamp.js). For a year past 9999, toISOString writes the expanded-year form, and PostgreSQL refuses that:
ERROR: time zone displacement out of range: "+010000-01-01T00:00:00.000Z" (SQLSTATE 22009)
PostgreSQL itself takes the year. select '10000-01-01T00:00:00.000Z'::timestamptz works, and its timestamps run to 294276 AD. Only the +010000- spelling is refused.
Repro:
constt=pgTable("t",{at: timestamp({withTimezone: true})});awaitdb.insert(t).values({at: newDate(Date.UTC(10000,0,1))});// DrizzleQueryError, cause: time zone displacement out of range (22009)
Expected: the row is written. For example, a year of 10000 or later could be sent without the sign and the zero padding, as 10000-01-01T00:00:00.000Z.
Where it bites: a time the application doesn't set itself. An API can take a date given in milliseconds where seconds were meant. Stripe takes a subscription's cancel_at of 1,800,000,000,000 s, which is the year 59009. Then every write of that row fails. We bound such times at 9999-12-31T23:59:59Z in the meantime.
Activity