You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Package versions and database engine type (please complete the following information):
Database Engine: postgres
TypeORM Version: 0.2.41
Driver Version 2.3.8
Describe the bug
When I do an insert for an entity with a generated date (timestamp) field like createdAt or updatedAt, the value in the resultant generatedMaps is a string, not a Date.
I would expect a Date object, just like I would get in the result of a find operation, but I end up getting a string. Worse, the string is missing the UTC Z at the end, so there is even more work to do to get it back to UTC time as a Date object.
Not only is the value on the generatedMaps incorrectly formatted, but also the mutated entity object passed into the insert call has the incorrectly formatted date:
const entity = { someField: true }
await getRepository(Entity).insert(entity)
/** insert call mutated the object passed in.
* now entity.createdAt exists and is not a Date, but a string.
* more complete example in repro section. **/
I'd be happy to fix this, but I need guidance
I'm not sure where the fix should go. It could go into this driver package. It could go into typeorm. It could also go into the data-api-client.
I think it should go into the data-api-client, and here is why:
There was a PR to address this issue but the relevant part of the fix was dropped by the owner while addressing merge conflicts before merging the PR.
From the requester's findings and my own, it looks like aws sends the typeName from executeStatement commands back in lowercase for postgres 😬 . The code in the data-api-client is written only to compare against uppercase typeName values. I monkey-patched the package and found that this issue was indeed fixed. However, I'm not sure if this is actually the correct layer for the fix.
What do you think?
opened a pr in the data-api-client repo to fix jeremydaly/data-api-client#117
worth noting that at the request of the author, this pr targets their aws sdk v3 migration branch, not main. so the fix won't be available until they release that version.
Thanks for your contribution!
Reading about your findings it looks like the best would be to fix it in the data-api-client.
Let's keep this open until the PR is merged so we can upgrade to the fixed data-api-client version when it's released.
Package versions and database engine type (please complete the following information):
Describe the bug
When I do an insert for an entity with a generated date (timestamp) field like
createdAt
orupdatedAt
, the value in the resultantgeneratedMaps
is a string, not aDate
.I would expect a Date object, just like I would get in the result of a
find
operation, but I end up getting a string. Worse, the string is missing the UTCZ
at the end, so there is even more work to do to get it back to UTC time as a Date object.Not only is the value on the generatedMaps incorrectly formatted, but also the mutated entity object passed into the insert call has the incorrectly formatted date:
I'd be happy to fix this, but I need guidance
I'm not sure where the fix should go. It could go into this driver package. It could go into typeorm. It could also go into the data-api-client.
I think it should go into the data-api-client, and here is why:
There was a PR to address this issue but the relevant part of the fix was dropped by the owner while addressing merge conflicts before merging the PR.
From the requester's findings and my own, it looks like aws sends the
typeName
fromexecuteStatement
commands back in lowercase for postgres 😬 . The code in the data-api-client is written only to compare against uppercasetypeName
values. I monkey-patched the package and found that this issue was indeed fixed. However, I'm not sure if this is actually the correct layer for the fix.What do you think?
To Reproduce
be sure to use
formatOptions.deserializeDate=true
entity class
use it
view that the
result
hasgeneratedMaps
withcreatedAt
as a timezone-less string. It should be a UTC Date.The text was updated successfully, but these errors were encountered: