Type error working with Postgres dates in v.0.30.1

I'm using Drizzle with postgresjs and recently updated to v0.30.1, where I know the driver was updated to always return strings for dates.

After the update, many of my queries then failed with an error ERR_INVALID_ARG_TYPE: The "string" argument must be of type string or an instance of Buffer or ArrayBuffer. Received an instance of Date".

Here's an example of a failed query that produced that error message:

const startDate = subDays(new Date(), 30) // Date object

const results = await db
  .select({
    id: sessions.id,
    userId: sessions.userId,
  })
  .from(sessions)
  .where(gte(sessions.timestamp, startDate))


Where sessions.timestamp is defined as timestamp('timestamp', { mode: 'date', withTimezone: true }) in my schema.

When I convert startDate to a string with .toISOString(), the query works, but I get the following type error:

No overload matches this call.
  Overload 1 of 3, '(left: PgColumn<{ name: "timestamp"; tableName: "sessions"; dataType: "date"; columnType: "PgTimestamp"; data: Date; driverParam: string; notNull: true; hasDefault: true; enumValues: undefined; baseColumn: never; }, {}, {}>, right: Date | SQLWrapper): SQL<...>', gave the following error.
    Argument of type 'string' is not assignable to parameter of type 'Date | SQLWrapper'.
  Overload 2 of 3, '(left: Aliased<string>, right: string | SQLWrapper): SQL<unknown>', gave the following error.
    Argument of type 'PgColumn<{ name: "timestamp"; tableName: "sessions"; dataType: "date"; columnType: "PgTimestamp"; data: Date; driverParam: string; notNull: true; hasDefault: true; enumValues: undefined; baseColumn: never; }, {}, {}>' is not assignable to parameter of type 'Aliased<string>'.


Any tips would be appreciated. Thank you!
Was this page helpful?