Repository navigation
Commit ccefb86
authored
fix: pad sub-microsecond digits when parsing nanosecond (#3614)
timestamp_to_nanos and timestamptz_to_nanos read the sub-microsecond
digits of the fraction (regex group 3 of ISO_TIMESTAMP_NANO /
ISO_TIMESTAMPTZ_NANO) as a bare integer. For a 7- or 8-digit fraction
that group is 1 or 2 digits and represents positions 7-8 of the
fraction, so it must be right-padded to 3 digits before being
interpreted as nanoseconds. Without padding, .1234567 was parsed as
+7 ns instead of +700 ns, silently corrupting the value.
Right-pad the group to 3 digits with ljust so all fraction widths
round-trip correctly, and add 7- and 8-digit cases to the tests, which
previously only covered 6- and 9-digit fractions.
Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>1 parent 800b56a commit ccefb86
2 files changed
Lines changed: 10 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
125 | 127 | | |
126 | 128 | | |
127 | 129 | | |
| |||
136 | 138 | | |
137 | 139 | | |
138 | 140 | | |
139 | | - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
140 | 144 | | |
141 | 145 | | |
142 | 146 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| 114 | + | |
| 115 | + | |
114 | 116 | | |
115 | 117 | | |
116 | 118 | | |
| |||
128 | 130 | | |
129 | 131 | | |
130 | 132 | | |
| 133 | + | |
| 134 | + | |
131 | 135 | | |
132 | 136 | | |
133 | 137 | | |
| |||
0 commit comments