Breaking Changes
The Postgres timestamp mapping has been changed to align all drivers with the same behavior.
❗ We’ve modified the postgres.js
driver instance to always return strings for dates, and then Drizzle will provide you with either strings of mapped dates, depending on the selected mode
. The only issue you may encounter is that once you provide the `postgres.js“ driver instance inside Drizzle, the behavior of this object will change for dates, which will always be strings.
We’ve made this change as a minor release, just as a warning, that:
-
If you were using timestamps and were waiting for a specific response, the behavior will now be changed. When mapping to the driver, we will always use
.toISOString
for both timestamps with timezone and without timezone. -
If you were using the
postgres.js
driver outside of Drizzle, allpostgres.js
clients passed to Drizzle will have mutated behavior for dates. All dates will be strings in the response.
Parsers that were changed for postgres.js
.
Ideally, as is the case with almost all other drivers, we should have the possibility to mutate mappings on a per-query basis, which means that the driver client won’t be mutated. We will be reaching out to the creator of the postgres.js
library to inquire about the possibility of specifying per-query mapping interceptors and making this flow even better for all users.
If we’ve overlooked this capability and it is already available with `postgres.js“, please ping us in our Discord!
A few more references for timestamps without and with timezones can be found in our docs
Check docs for getting started with postgres.js
driver and Drizzle here
Fixes
- timestamp with mode string is returned as Date object instead of string - (#806)
- Dates are always dates (#971)
- Inconsistencies when working with timestamps and corresponding datetime objects in javascript. (#1176)
- timestamp columns showing string type, however actually returning a Date object. (#1185)
- Wrong data type for postgres date colum (#1407)
- invalid timestamp conversion when using PostgreSQL with TimeZone set to UTC (#1587)
- Postgres insert into timestamp with time zone removes milliseconds (#1061)
- update timestamp field (using AWS Data API) (#1164)
- Invalid date from relational queries (#895)