Dates serialized without quotation marks in query event parameters property
See original GitHub issueBug description
The dates in Prisma query event parameters
property are serialized without "
making it impossible to parse is as JSON out of the box.
Example:
["DRAFT","test-tenant-uuid","ONGOING","SCHEDULED","COMPLETED",2021-04-14 13:25:26.778 UTC,2021-04-14 13:25:26.779 UTC,101,0]
. String values are enclosed with "
, numbers naturally are not (but it is fine). With dates on the other hand it is not okay. If normal literal values are enclosed why not dates if they are stored in a property of type string
. Additionally in SQL queries Date type columns are comparable with string representation.
How to reproduce
- Register event handler:
prisma.$on('query' as any, async (e) => {
const eventObj = e as Prisma.QueryEvent;
const params = JSON.parse(eventObj.params); // error
- Run any query with date/datetime filter parameters:
...
where: {
startDate: { gte: filters?.dates?.[0] },
endDate: { lte: filters?.dates?.[1] },
},
// filters.dates is an 2 element array of js Date type and both columns are of type DateTime
Expected behavior
Well, keeping the parameters in an array serialized to string is problematic in the first place but it wouldn’t be a problem if we could parse it as a JSON, and I expected that it is always possible. If not and it is okay, is it really expected here to fix it by hand using string regexes/split/joins etc?
My use case here is that I am developing pretty debug log of the queries which can executed on the db 1:1.
Prisma information
Not relevant.
Environment & setup
- OS: Windows 10
- Database: MySQL 8+
- Node.js version: 15.10
- Prisma version: ^2.20.1
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6 (2 by maintainers)
Top GitHub Comments
No, I am not using this flag.
The arguments are serialized on the engine side, client just forwards this string as-is