Commit 6d8c005
committed
fix(pg): throw on invalid Date instead of serializing NaN string
new Date(undefined) and new Date('invalid') produce an invalid Date
object whose getTime() returns NaN. Previously prepareValue() would
pass such a date straight through to dateToString() / dateToStringUTC()
which format each NaN component with padStart(), producing the
meaningless string '0NaN-NaN-NaNTNaN:NaN:NaN.NaN+NaN:NaN' that Postgres
cannot parse.
Add an isNaN(val.getTime()) guard in the isDate branch of prepareValue()
and throw an informative error immediately, so callers discover the bug
at the JS level rather than receiving a cryptic Postgres error.
Fixes #33181 parent c78b302 commit 6d8c005
2 files changed
+19
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
67 | 70 | | |
68 | 71 | | |
69 | 72 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
97 | 113 | | |
98 | 114 | | |
99 | 115 | | |
| |||
0 commit comments