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:
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:
Any tips would be appreciated. Thank you!7 Replies
Giving this a quick bump to see if anyone else has experienced this or has any tips to solve. It's currently blocking me from upgrading to v 0.30.x, so I'm very curious. Thanks!
@terryball I had a similar problem to you upgrading to 0.30.x and couldn't get queries with dates inside
gte
working — for me I ended up replacing the gte/lte
calls with between
which doesn't seem to have the same issue. For example:
between(posts.created_at, startDate, endDate),
but that doesn't seem ideal if you don't want to pass in an endDate
(could just set it to now though).
I plan to look deeper to see what the actual issue is laterInteresting, ok thanks @nateeo
it may depend on the mode you are using for the column, no?
seeing this too, even when I have the column in date mode, I get a typescript error if i have it as a iso string, and a runtime error if i leave it as a date. The between fix doesn't even work for me 😦
@Angelelz
any update for this?
this has been resolved for ages now I think