Skip to content
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

fix: postgres.js date serialiser #3168

Open
wants to merge 3 commits into
base: beta
Choose a base branch
from

Conversation

TypicalDefender
Copy link

Passing a Date object will result in an error: The "string" argument must be of type string or an instance of Buffer or ArrayBuffer

Comment on lines +31 to +33
if (Object.prototype.toString.call(val) === '[object Date]') {
return (val as Date).toISOString();
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use val instanceof Date?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is safer because instanceof might return false if the Date object comes from another realm.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof#instanceof_and_multiple_realms

@AndriiSherman AndriiSherman changed the base branch from main to beta November 3, 2024 09:20
@deanrih
Copy link

deanrih commented Nov 21, 2024

isn't this the same with PR #2839 ?

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

Successfully merging this pull request may close these issues.

5 participants