Disallow date fields from working with Date objects? #134
IlyaSemenov
started this conversation in
General
Replies: 1 comment
-
|
I saved it to an issue to work on it later: #179 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I noticed in raw SQL logs that when I insert a date column and pass an ISO date, it's converted to Javascript Date before it's sent to the database:
I then noticed that I can even pass a raw Date object:
I think this is a time bomb for timezone errors and should be disallowed. In the
new Date()example above, the actual value saved to the database will depend on the time zone of the Postgres host. If the app works in EST and the database runs on a server in UTC, I thinknew Date()will save the tomorrow's date when it's 9pm in New York - something that a naive user wouldn't expect. Moreover, this kind of problems could be left unnoticed in unit tests when the server and the app work on the same server.So my point here is that
t.date()should better work with strings only to prevent misuse (possibly allowing to opt-in for dates withasDatefor those who are absolutely sure they can handle tz offsets properly). What do you think?Beta Was this translation helpful? Give feedback.
All reactions