My columns are set to be "timestamp with timezone". One of my tables also uses timestampz(6). When looking at the values in the database, they all appear to be the same: "2023-05-25 10:26:32.809521 +00:00". However, when I pass a date object to Prisma, it formats the param in an odd way: "params": "[\"2023-03-25 10:26:32.809 UTC\",0]",
This results in no records being found. I can confirm this by running my own queries using raw sql:
SELECT * FROM audit.record_version where audit.record_version.ts = '2023-05-25T10:26:32.809Z'; \\No Records Found
SELECT * FROM audit.record_version where audit.record_version.ts = '2023-05-25 10:26:32.809521 +00:00'; //Records found
It would appear that Prisma is converting my Date object into a String and if I pass in a string date, it still transforms it into the same UTC string format shown above.
Question: How can I get Prisma to send the param in the correct format ("'2023-05-25 10:26:32.809521 +00:00'")?
For further context, here is the where clause being sent to my resolver:
"ts": {
"equals": row.ts)
}
row.ts references a Date object. Even if I set the date to a string (i.e. `"equals": "2023-05-25 10:26:32.809521 +00:00") it still gets converted to the UTC string. It's also truncating the millisecond field, but I'm not sure if that's an issue yet. I feel like I'm making a stupid mistake, but I can't tell what that is from the documentation I'm reading. Does anyone have an idea as to why Prisma is converting my Date object into UTC instead of +00:00?
It turns out my issue was a bit different then I thought it was. The issue was that Prisma was droping the precision of my milliseconds from a precision of 6 to a precision of 3 (the default). It may be a bug in Prisma as no amount of specifying the higher precision (
@db.timestamptz(6)) would cause it to alter it's representation. So, I took the easy way and converted my DB column to have a precision of 3 and everything seems to be working now. A precision of 3 is probably just fine, but I'm annoyed that I couldn't get Prisma to submit a query param with the higher precision.