"Cannot parse date or time" using AWS Data API, aurora postgres
I'm trying drizzle-orm (with sst) and aurora pg thru aws data api, when trying to insert a Date value in a column (timestamp with timezone), I'm getting this error. I wonder if the problem is the way Date is being serialized (looks like it's not using ISO date string?)
this shows the response coming from aws-data-api
11 Replies
turned the logger on, and effectively it shows this:
the query (the updatedAt is the offending line, error goes away if I comment that one)
"drizzle-orm": "^0.27.2",
I'm getting the same error with the same set up. Did you end up finding a solution?
nope, I just skipped that field bc it was a small pet project, but have no solution yet
using AWS Data API (maybe related to this specific driver)
I created this as github issue here: https://github.com/drizzle-team/drizzle-orm/issues/1164
GitHub
[BUG]: update timestamp field (using AWS Data API) · Issue #1164 · ...
What version of drizzle-orm are you using? 0.27.2 What version of drizzle-kit are you using? 0.19.5 Describe the Bug I'm trying drizzle-orm (with sst) and aurora pg thru aws data api, when tryi...
I just submitted a PR that I think solves this issue. I'd love some feedback if it could be better: https://github.com/drizzle-team/drizzle-orm/pull/1316
GitHub
[AwsDataApi] Handle timestamp by kyen99 · Pull Request #1316 · driz...
Convert ISO or UTC datetime string to AWS Data API date format
AWS Data API requires a specific date formatting that is different than the ISO or UTC date string. Per this document: https://docs.aw...
thank you, let’s hope it makes it into next version. I moved on but happy to at least help test when ready
this was working for me for a while, but now this same issue appears to exist with between query filters when the value is a date object and when inserting again:
i'm using a pg table with the following column:
time: timestamp('time', { mode: 'date', withTimezone: true }).notNull(),
BadRequestException: Cannot parse date or time " hu, 22 Feb 2024 12:20:00 GMT"
I removed the
withTimezone
property in my timestamp
and now everything works and I encountered this problem when trying to use Nextjs + Drizzle + Lucia Auth.
I’m not sure I want to remove the with timestamp. It appears drizzle is setup to convert date objects to ISO strings and then replace the T and the Z but for me it’s just using toString and still replacing the T, which you see when the T in Thurs is replaced with a space
Yeah I thought about the consequences of removing
withTimezone
too. Currently I am trying to find a solution in which I don't remove the withTimezone
.The problem appears to be in
drizzle-orm/pg-core/columns/timestamp.js
. The offending code is:
the toUTCString()
doesnt work for the data api, so I am going to make a patch where I just always congvert it to an ISO string. I'm assuming this has other implications for other drivers, but I don't know enough about that