Skip to content

Why are "date" fields forced to Date objects? #3290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
markedwards opened this issue Aug 5, 2024 · 4 comments
Closed

Why are "date" fields forced to Date objects? #3290

markedwards opened this issue Aug 5, 2024 · 4 comments

Comments

@markedwards
Copy link

It is reasonable and correct for "timestamp" fields to be converted to/from Javascript Date objects. But it is not reasonable that the same happens to "date" fields. This data type does not have a timezone or any time information at all, but it is being falsely added by pg.

Is there any chance at this point of this behavior changing? Other libraries like TypeORM are actually fixing this bad behavior, but not when raw query results are returned. Its super confusing.

@brianc
Copy link
Owner

brianc commented Aug 5, 2024 via email

@charmander
Copy link
Collaborator

Duplicate of #1844

@charmander charmander marked this as a duplicate of #1844 Aug 6, 2024
@charmander charmander closed this as not planned Won't fix, can't repro, duplicate, stale Aug 6, 2024
@charmander
Copy link
Collaborator

charmander commented Aug 6, 2024

Other libraries like TypeORM are actually fixing this bad behavior, but not when raw query results are returned.

Until pg gets the new major version of pg-types, libraries that depend on it should ideally be overriding the date type parser instead of converting the Date back into a string, which would also fix this kind of discrepancy.

@markedwards
Copy link
Author

@brianc, just wanted to follow up belatedly here thank you for the fast and candid response. Many would have ignored this, or been defensive, and you gave a straight answer. Really appreciate that.

It would be great to see this fixed ultimately, but I fully understand the challenge here.

I'll bug TypeORM for a proper fix here, but unfortunately for now I have to settle for converting the value after the fact.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants